Update Tensorboard use

This commit is contained in:
Matteo Bertocchi
2025-03-11 12:01:06 +01:00
committed by Nicola Demo
parent b38b0894b1
commit 67a2b0796c
6 changed files with 58 additions and 137 deletions

View File

@@ -194,12 +194,11 @@ trainer.train()
# Let's now plot the logging to see how the losses vary during training. For this, we will use `TensorBoard`.
# In[5]:
# In[ ]:
# Load the TensorBoard extension
get_ipython().run_line_magic('load_ext', 'tensorboard')
get_ipython().run_line_magic('tensorboard', "--logdir 'tutorial_logs'")
print('\nTo load TensorBoard run load_ext tensorboard on your terminal')
print("To visualize the loss you can run tensorboard --logdir 'tutorial_logs' on your terminal\n")
# Notice that the loss on the boundaries of the spatial domain is exactly zero, as expected! After the training is completed one can now plot some results using the `matplotlib`. We plot the predicted output on the left side, the true solution at the center and the difference on the right side using the `plot_solution` function.
@@ -335,12 +334,12 @@ plt.figure(figsize=(12, 6))
plot_solution(solver=pinn, time=1)
# We can see now that the results are way better! This is due to the fact that previously the network was not learning correctly the initial conditon, leading to a poor solution when time evolved. By imposing the initial condition the network is able to correctly solve the problem. We can also see using Tensorboard how the two losses decreased:
# We can see now that the results are way better! This is due to the fact that previously the network was not learning correctly the initial conditon, leading to a poor solution when time evolved. By imposing the initial condition the network is able to correctly solve the problem. We can also see how the two losses decreased using Tensorboard.
# In[11]:
# In[ ]:
get_ipython().run_line_magic('tensorboard', "--logdir 'tutorial_logs'")
print("To visualize the loss you can run tensorboard --logdir 'tutorial_logs' on your terminal")
# ## What's next?