msurtsukov / neural-ode

Jupyter notebook with Pytorch implementation of Neural Ordinary Differential Equations
697 stars 119 forks source link

conduct experiment #2

Open magus96 opened 5 years ago

magus96 commented 5 years ago

Getting the following error.


RuntimeError Traceback (most recent call last)

in () ----> 1 conduct_experiment(ode_true, ode_trained, 500, "linear") in conduct_experiment(ode_true, ode_trained, n_steps, name, plot_freq) 38 39 optimizer.zero_grad() ---> 40 loss.backward(retain_graph=True) 41 optimizer.step() 42 /usr/local/lib/python3.6/dist-packages/torch/tensor.py in backward(self, gradient, retain_graph, create_graph) 91 products. Defaults to ``False``. 92 """ ---> 93 torch.autograd.backward(self, gradient, retain_graph, create_graph) 94 95 def register_hook(self, hook): /usr/local/lib/python3.6/dist-packages/torch/autograd/__init__.py in backward(tensors, grad_tensors, retain_graph, create_graph, grad_variables) 88 Variable._execution_engine.run_backward( 89 tensors, grad_tensors, retain_graph, create_graph, ---> 90 allow_unreachable=True) # allow_unreachable flag 91 92 RuntimeError: Function ODEAdjointBackward returned an invalid gradient at index 2 - expected shape [4] but got [1, 4]
msurtsukov commented 5 years ago

On my machine notebook runs end-to-end both with and without cuda. Pytorch version - 1.0.0.

magus96 commented 5 years ago

My issue is that [1,354] and [354] are the same vector shapes and Pytorch should automatically detect that.