Skip to content

Conversation

@TheCSGuy25
Copy link
Contributor

Added the Plot Loss Method, that accepts an emulator along with optional plot title and figure size as arguments and will plot the loss with respect to epochs and will raise an AttributeError if the emulator has no loss_history attribute.

@radka-j
Copy link
Member

radka-j commented Nov 26, 2025

Thank you for adding this @TheCSGuy25, it looks great!

The only thing that needs fixing is the pre-commit and then it's good to merge. Let us know if you need any help with this.

@TheCSGuy25
Copy link
Contributor Author

Hey @radka-j

I will change the test and exceptions as suggested by the workflow. I have a question related to message that was shown as a part of it

plotting.py:642:25 - error: Cannot access attribute "loss_history" for class "Emulator" Attribute "loss_history" is unknown (reportAttributeAccessIssue) 1 error, 0 warnings, 0 informations

I looked at the base.py and PytorchBackend class has a loss_history object but not the Emulator class. How do i resolve this? As we're passing the emulator not the Base model to the plot_loss method, or should i change it to a PyTorchBackend model?

@radka-j
Copy link
Member

radka-j commented Dec 10, 2025

@TheCSGuy25 thank you for checking

There are two options:

  1. As you say, you could change the type to PyTorchBackend - this is the simplest but I'd prefer to avoid this as we should ideally also be tracking the loss history in the gaussian process emulators (which don't inherit from PyTorchBackend).
  2. change the code to something like:
    if not hasattr(model, "loss_history"):
        msg = "Emulator does not have a Loss history"
        raise AttributeError(msg)
    history = model.loss_history

This is essentially what you implemented but should (I think) satisfy the pre-commit check.

Let me know if you have any questions and/or anything else comes up.

@radka-j radka-j linked an issue Dec 10, 2025 that may be closed by this pull request
@TheCSGuy25
Copy link
Contributor Author

TheCSGuy25 commented Dec 15, 2025

@radka-j Hello !

So it passed the pre-commit, but now it show's an issue with coverage_from_distributions method from plotting.py

AttributeError: 'Tensor' object has no attribute 'sample'

as well as
No module named 'autoemulate.simulations_design', No module named 'autoemulate.simulations_design

Do let me know how i can help to resolve this.

(Note: I have synced the fork and branches with the main as well)

@radka-j
Copy link
Member

radka-j commented Dec 16, 2025

@TheCSGuy25 this all looks great! The bug had something to do with the docs and is not related to this PR. Thank you again for implementing this and for your patience with getting the CI to pass :)

@radka-j radka-j self-requested a review December 16, 2025 13:09
@radka-j radka-j merged commit bc3ee05 into alan-turing-institute:main Dec 16, 2025
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Training loss diagnostics plot

2 participants