Add history_ attribute to DNN models for training loss tracking - #712
Add history_ attribute to DNN models for training loss tracking#712jiyanshuj wants to merge 2 commits into
Conversation
Fixes yzhao062#636 - Add self.history_ dict ({'loss': [...]}) to BaseDeepLearningDetector and all standalone DNN-based detectors (AutoEncoder, VAE, ALAD, AnoGAN, DeepSVDD, DevNet, LUNAR, MO_GAAL, SO_GAAL, TS-LSTM, TS-AnomalyTransformer, AE1SVM) - Update docstrings to document the new attribute - Add unit tests verifying history_['loss'] is populated per epoch - Retain existing verbose printing behavior (noting DevNet's console print now outputs the mean epoch loss rather than the last batch loss)
There was a problem hiding this comment.
Pull request overview
Adds a history_ attribute to deep-learning-based detectors so callers can retrieve training loss information after fit() (addressing issue #636), and extends the test suite to assert the history is populated.
Changes:
- Track and expose per-epoch training loss via
history_acrossBaseDeepLearningDetector-based models and several standalone DNN detectors. - Update model docstrings and
CHANGES.txtto document the newhistory_attribute. - Add/extend unit tests to validate
history_is present and populated after fitting.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
pyod/models/base_dl.py |
Initializes/resets and appends to history_['loss'] during training in the shared deep-learning base class. |
pyod/models/auto_encoder.py |
Documents inherited history_ for AutoEncoder. |
pyod/models/vae.py |
Documents inherited history_ for VAE. |
pyod/models/deep_svdd.py |
Adds history_ initialization and records per-epoch loss. |
pyod/models/ae1svm.py |
Adds history_ and records per-epoch mean loss (also reuses that value for best-loss tracking/printing). |
pyod/models/devnet.py |
Adds history_ and records per-epoch mean loss (also changes printed loss value). |
pyod/models/lunar.py |
Adds history_ and records loss each epoch. |
pyod/models/ts_lstm.py |
Adds history_ and records mean batch loss per epoch during training. |
pyod/models/ts_anomaly_transformer.py |
Adds history_ and records per-epoch mean minimize-phase loss. |
pyod/models/anogan.py |
Adds history_ mapping to GAN loss histories; reinitializes on fit(). |
pyod/models/alad.py |
Adds history_ mapping to GAN loss histories during model build/fit. |
pyod/models/so_gaal.py |
Exposes existing train_history via history_ and documents it. |
pyod/models/mo_gaal.py |
Exposes existing train_history via history_ and documents it. |
pyod/test/test_auto_encoder.py |
Adds assertions that history_['loss'] exists and has epoch_num entries. |
pyod/test/test_vae.py |
Adds assertions that history_['loss'] exists and has epoch_num entries. |
pyod/test/test_deepsvdd.py |
Adds assertions that history_['loss'] exists and has epochs entries. |
pyod/test/test_anogan.py |
Adds assertions for GAN loss keys in history_. |
pyod/test/test_alad.py |
Adds assertions for GAN loss keys in history_. |
pyod/test/test_so_gaal.py |
Adds assertions for GAN loss keys in history_. |
pyod/test/test_mo_gaal.py |
Adds assertions for GAN loss keys in history_. |
CHANGES.txt |
Adds release-note entry for the new history_ attribute. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c0e54c06c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- Ensure self.history_ is set exclusively in fit() across all models - Explicitly cast overall_loss to float in BaseDeepLearningDetector.train - Address PR review comments
2c0e54c to
69ac31d
Compare
Fixes #636
All Submissions Basics:
All Submissions Cores:
New Model Submissions: