DiffEqML / torchdyn

A PyTorch library entirely dedicated to neural differential equations, implicit models and related numerical methods
https://torchdyn.org
Apache License 2.0
1.36k stars 125 forks source link

Hypersolver Tutorial Figure #104

Closed pharringtonp19 closed 3 years ago

pharringtonp19 commented 3 years ago

Just noticed that the plot that shows the difference between the tsit5 solver and the hypersolver plots the same output dimension three times instead of plotting the three output dimensions

fig = plt.figure(figsize=(15, 14))
axs = fig.subplots(6,1)
axs[0].plot(sol[:,:4,0], c='black'); axs[2].plot(sol[:,:4,1], c='r'); axs[4].plot(sol[:,:4,2], c='b');
axs[0].set_xticks([]); axs[2].set_xticks([]); axs[4].set_xticks([])
# The error accumulates as Euler (base solver of HyperEuler) does not converge here. 
# Here we plot the errors (mean across batches of initial conditions)
axs[1].plot((sol-sol_gt)[:,:4,0].abs().mean(1), c='black')
axs[1].set_title('Error on $x_0$')
axs[3].plot((sol-sol_gt)[:,:4,0].abs().mean(1), c='r')
axs[3].set_title('Error on $x_1$')
axs[5].plot((sol-sol_gt)[:,:4,0].abs().mean(1), c='b');
axs[5].set_title('Error on $x_2$')
Zymrael commented 3 years ago

Good catch, thanks. The error is now computed averaging across all samples and summing across states.