Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with lower dimensional mappings within f #125

Open
nprasadmm opened this issue Jan 6, 2022 · 3 comments
Open

Error with lower dimensional mappings within f #125

nprasadmm opened this issue Jan 6, 2022 · 3 comments
Labels
question Further information is requested

Comments

@nprasadmm
Copy link

nprasadmm commented Jan 6, 2022

I'm not sure if this is a bug, an error in my code, or by design, but my ODE errors out unless input_dim == output_dim at all steps within the f function. For example, if I were to apply the layer nn.Linear(18, 2), I would get the following error:

             File "/home/ubuntu/anaconda3/envs/storage-env/lib/python3.9/site-packages/torchdyn/core/neuralde.py", line 93, in forward
t_eval, sol =  super().forward(x, t_span)
             File "/home/ubuntu/anaconda3/envs/storage-env/lib/python3.9/site-packages/torchdyn/core/problems.py", line 79, in forward
return self.odeint(x, t_span)
             File "/home/ubuntu/anaconda3/envs/storage-env/lib/python3.9/site-packages/torchdyn/core/problems.py", line 75, in odeint
return self.autograd_function(self.vf_params, x, t_span)
             File "/home/ubuntu/anaconda3/envs/storage-env/lib/python3.9/site-packages/torchdyn/numerics/sensitivity.py", line 37, in forward
t_sol, sol = generic_odeint(problem_type, vf, x, t_span, solver, atol, rtol, interpolator, B, 
             File "/home/ubuntu/anaconda3/envs/storage-env/lib/python3.9/site-packages/torchdyn/numerics/sensitivity.py", line 24, in generic_odeint
return odeint(vf, x, t_span, solver, atol=atol, rtol=rtol, interpolator=interpolator, return_all_eval=return_all_eval)
            File "/home/ubuntu/anaconda3/envs/storage-env/lib/python3.9/site-packages/torchdyn/numerics/odeint.py", line 83, in odeint
return _fixed_odeint(f_, x, t_span, solver) 
           File "/home/ubuntu/anaconda3/envs/storage-env/lib/python3.9/site-packages/torchdyn/numerics/odeint.py", line 412, in _fixed_odeint
_, x, _ = solver.step(f, x, t, dt)
           File "/home/ubuntu/anaconda3/envs/storage-env/lib/python3.9/site-packages/torchdyn/numerics/solvers.py", line 89, in step
k2 = f(t + c[0] * dt, x + dt * (a[0] * k1))
           RuntimeError: The size of tensor a (18) must match the size of tensor b (2) at non-singleton dimension 1

This also happens if other dimensions change through pooling operations. I would appreciate any help in resolving this.

@nprasadmm nprasadmm added the question Further information is requested label Jan 6, 2022
@Zymrael
Copy link
Member

Zymrael commented Jan 6, 2022

You are explicitly parametrizing the derivative (i.e. vector field) with your neural network, which has to have the same dimension as the state.

@nprasadmm
Copy link
Author

I see. So assuming my neural network operates on a batch of 18-dimensional vectors, how would I plot the flows for this ode? Would I have to run t-SNE on each step of the trajectory to reduce to 2D vectors?

@1209098482
Copy link

nice,i have same problem,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants