Animate the Learning Process for 1D Burgers emulation¤
Using APEBench's callbacks
import jax.numpy as jnp
import seaborn as sns
import matplotlib.pyplot as plt
from IPython.display import Video
import apebench
burgers_scenario = apebench.scenarios.difficulty.Burgers(
num_points=60,
# optim_config="adam;10000;constant;3e-4",
callbacks="sample_rollout;10", # will call the sample_rollout callback every 5 update steps
record_loss_every=1,
)
Training now takes ~15 min instead of 1 min due to the callback overhead
data, net = burgers_scenario()
loss_data = apebench.melt_loss(data)
sns.lineplot(data=loss_data, x="update_step", y="train_loss")
plt.yscale("log")
aux_data = apebench.melt_data(data, "aux", "update_step")
aux_data
aux_data["sample_rollout"] = aux_data["aux"].apply(lambda x: x["sample_rollout"])
optim_trj = jnp.concatenate(list(aux_data.iloc[::10]["sample_rollout"].values))
optim_trj.shape
ani = apebench.exponax.viz.animate_spatio_temporal(optim_trj)
ani.save("burgers_optim_rollout.mp4")
Video(
url="https://github.com/Ceyron/Ceyron/assets/27728103/70a5a9a7-efac-44d1-92b8-290e75fb0396"
)