Skip to content

fix: pickle and deep copy classification models with EP#1108

Merged
MartinBubel merged 2 commits intoSheffieldML:develfrom
olamarre:bugfix/ep-pickling
Jan 15, 2025
Merged

fix: pickle and deep copy classification models with EP#1108
MartinBubel merged 2 commits intoSheffieldML:develfrom
olamarre:bugfix/ep-pickling

Conversation

@olamarre
Copy link
Contributor

@olamarre olamarre commented Jan 4, 2025

  • Removed unecessary code preventing pickling & copying
  • Wrote a new test to check that pickling and copying works

Fixes #1105

Longer description:

  • Removed all the "super" commands in the EPBase class since it does not have parent classes (raises an error otherwise - I suspect methods employing this command were never used or tested).
  • Removed the __setstate__ and __getstate__ methods as they did not fully capture the state of an instance, making the implementation brittle. An error would be raised when pickling and unpickling an instance (for example, the self.always_reset attribute was missing). By removing these instances, Python now defaults to using the __dict__ method of the class, which works well and is much simpler.
  • Added a test to validate that picking and deep copying now works with a classification model using expectation-propagation (ran test with pytest 8.3.4, GPy version 1.13.2 and Python 3.9.19)

- Removed unecessary code preventing pickling & copying
- Wrote a new test to check that pickling and copying works
@MartinBubel MartinBubel self-requested a review January 15, 2025 18:16
@MartinBubel
Copy link
Contributor

thanks @olamarre for your contribution. LGTM!
I have updated the changelog (noting your contribution) and I will merge it after the pipeline finishes.

If you need a new release featuring the fix, raise your hand - then I'll trigger the release pipeline.

@MartinBubel MartinBubel merged commit acdd03d into SheffieldML:devel Jan 15, 2025
15 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.

Errors when copying or pickling models using the expectation_propagation.EP() class

2 participants