Skip to content

[ENH] Refactor deep learning autoencoders clusterer - #3904

Open
melpiro wants to merge 54 commits into
mainfrom
mp/fix_abgru_and_bgru_to_rnn
Open

melpiro wants to merge 54 commits into
mainfrom
mp/fix_abgru_and_bgru_to_rnn

Conversation

@melpiro

@melpiro melpiro commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

Reference Issues/PRs

#3897

What does this implement/fix? Explain your changes.

This PR refactors the deep-learning clustering infrastructure to reduce code duplication, improve consistency, and make the autoencoder implementations more extensible.

Changes

Shared deep-learning infrastructure

  • Refactor deep autoencoder networks and clusterers to use shared base classes.
  • Add encoder-only and decoder-only prediction methods.
    • predict_encoder gives the latent space representation of an input
    • predict_decoder allows getting the reconstructed time series from a latent space representation
  • In DeepAENetworks, make build_network for the AE model identical to other networks:
    • build_network returns the input layer and output layer of the whole network architecture
    • add get_encoder_model to get the encoder as tf.keras.Model
    • add get_decoder_model to get the decoder as tf.keras.Model
    • add get_autoencoder_model to get the whole architecture as tf.keras.Model
    • add get_encoder_decoder_models to get the tuple: (encoder, decoder) as tf.keras.Model
  • Improve multi-reconstruction training efficiency by reducing redundant model calls.

Latent-space representations

  • Introduce a new latent space type: Repeated
    • Use RepeatVector to reconstruct a time series from a 1D latent space
    • Commonly used with RNN autoencoder
  • Replace parameter temporal_latent_space with enum parameter latent_space_type:
    • LATENT_SPACE.FLAT default behaviour as before
    • LATENT_SPACE.TIME equivalent to temporal_latent_space=true
    • LATENT_SPACE.REPEATED the new RepeatVector-based latent space
  • When the number of channels already matches the latent space dimensionality, automatically skip Conv1D layers with kernel_size=1 used for resizing the number of channels

Recurrent autoencoders

  • Introduce AERecurrentNetwork and AERecurrentClusterer (replacing AEBiGRU).
  • Support configurable recurrent cell types through RNN_TYPE.
  • Support configurable residual connections
  • Support bidirectional layers
  • Support attention

Old AEBiGruNetwork is the exact equivalent of :

from aeon.typing import LATENT_SPACE, RNN_TYPE
from aeon.networks import AERecurrentNetwork

rnn = AERecurrentNetwork(
    latent_space_type=LATENT_SPACE.REPEATED,
     rnn_type=RNN_TYPE.GRU,
     n_layers=2,
     n_units=[50, 64],
     bidirectional=True,
     activation="relu",
)

DeTSEC

  • Rename the previous attention-based bidirectional GRU implementation AEABiGRU to AEDeTSECNetwork and AEDeTSECClusterer.
  • Correct the implementation to follow the original DeTSEC paper, including attentive-gated embedding and bidirectional reconstruction.

Fixes and improvements

  • Fix dtype handling in ba_petitjean.py.
  • Avoid unnecessary Conv1D transformations when the input and output shapes already match.
  • When fitting DeepAEClusterer, prevent the duplicate display of the MSE as a loss and then as a metric.

Does your contribution introduce a new dependency? If yes, which one?

No

Any other comments?

PR checklist

For all contributions
  • I've added myself to the list of contributors. Alternatively, you can use the @all-contributors bot to do this for you after the PR has been merged.
  • The PR title starts with either [ENH], [MNT], [DOC], [BUG], [REF], [DEP] or [GOV] indicating whether the PR topic is related to enhancement, maintenance, documentation, bugs, refactoring, deprecation or governance.
For new estimators and functions
  • I've added the estimator/function to the online API documentation.
  • (OPTIONAL) I've added myself as a __maintainer__ at the top of relevant files and want to be contacted regarding its maintenance. Unmaintained files may be removed. This is for the full file, and you should not add yourself if you are just making minor changes or do not want to help maintain its contents.
For developers with write access
  • (OPTIONAL) I've updated aeon's CODEOWNERS to receive notifications about future changes to these files.

melpiro and others added 30 commits September 4, 2026 15:16
+ refactor parameter checking in every build_network() method using a new function named _check_params()
… Fixs + refectors

Fix rnn cell type checking
Fix error when dropout intermediate is given as list
Disable first residual between input layer and first rnn cell when not using an explicit list
…encoder

rename ae abgru to aeDeTSEC and fix its implementation to correspond to its paper
improve multi_rec training by only having one model call for every loss calculation (avoiding having one call per loss)
add enum for autoencoder latent space type
fix missing constructor parameter: latent_space_dim or latent_space_type that are in the doc but not in the constuctor of deepClusterer ...
make ae reshapes using conv1D kernel_size1 optional if shapes already match latent space dim
improved overall code quality
fix dtype bug in ba_petitjean.py
add predict_encoder and predict_decoder in base clusterer (predicting latent proj + reconstructing)
remove mse loss from metrics as it is a duplicate of "loss" by default
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@aeon-actions-bot aeon-actions-bot Bot added the enhancement New feature, improvement request or other non-bug code enhancement label Oct 12, 2026
@aeon-actions-bot

Copy link
Copy Markdown
Contributor

Thank you for contributing to aeon

I have added the following labels to this PR based on the title: enhancement.
This PR changes too many different packages (>3) for automatic addition of labels, please manually add package labels if relevant.

The Checks tab will show the status of our automated tests. You can click on individual test runs in the tab or "Details" in the panel below to see more information if there is a failure.

If our pre-commit code quality check fails, please run pre-commit locally and push the fixes to your PR branch.

Don't hesitate to ask questions on the aeon Discord channel if you have any.

PR CI actions

These checkboxes will add labels to enable or disable CI functionality for this PR. This may not take effect immediately, and a new commit may be required to run the new configuration.

  • Run pre-commit checks for all files
  • Run mypy typecheck tests
  • Run all pytest tests and configurations
  • Run all notebook example tests
  • Run numba-disabled codecov tests
  • Disable numba cache loading
  • Regenerate expected results for testing
  • Push an empty commit to re-run CI checks

@melpiro melpiro self-assigned this Oct 12, 2026
@melpiro melpiro linked an issue Oct 14, 2026 that may be closed by this pull request
@MatthewMiddlehurst MatthewMiddlehurst added clustering Clustering package deep learning Deep learning related labels Oct 27, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clustering Clustering package deep learning Deep learning related enhancement New feature, improvement request or other non-bug code enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH] Refactor deep learning autoencoders clusterer

2 participants