Harden and complete the autoencoder API#153
Open
sergioald wants to merge 1 commit into
Open
Conversation
Collaborator
Author
|
Ruff note: the new API code and the critical syntax/undefined-name checks for the modified architecture files pass successfully. A full Ruff run over bluemath_tk/deeplearning still reports pre-existing style issues in develop, mainly in autoencoders.py, layers.py, metrics.py, unet.py, and some existing tests. I have therefore avoided mixing this PR with an unrelated package-wide lint cleanup. The focused checks pass, and the full test suite completes successfully with 241 tests passed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR hardens the existing autoencoder training path and completes the public
autoencoder API.
It combines four related improvements:
Changes
Training and input robustness
validation_split,batch_size,epochs, andpatiencea leading sample dimension
BatchNorm1dbatch_size=1clearly for those models instead of failing insidePyTorch
sample
batch_size=1for models that do not containBatchNorm1dLatentDecorrneutral when sample covariance is undefined for aone-sample batch
batch sizes
The existing train/validation loss-history aggregation semantics are retained.
Reconstruction convenience API
model.reconstruction_error(...)model.evaluate_reconstruction(...)model.evaluate(...)as a concise aliasbluemath_tk.deeplearning.metricsConvLSTMAutoencoderandHybridConvLSTMTransformerAutoencoderDecode API
model.decode(Z)decode_forward()implementations for all seven existingautoencoders
decode(encode(X))reproduces the same inference path aspredict(X)Checkpoint improvements
load_pytorch_model(...)ClassName.from_pytorch_model(...)for one-step restorationmodel
These are model checkpoints; optimizer state is intentionally outside this
PR's scope.
Tests
predict(X)anddecode(encode(X))batch_size=1behaviour with and withoutBatchNorm1dScope
This PR does not add a new model architecture and does not change the
mathematical definition of the accepted reconstruction metrics. It makes the
existing autoencoders safer to train, easier to evaluate and decode, and
portable between sessions.
Local validation
The warnings are existing dependency and project warnings, primarily from
cmocean/Matplotlib, Shapely, GPyTorch, and interpolation tests. No test failed.