Skip to content

[ENH] Salute Tensorflow, move to Keras 3 #2751

Open
@Ball-Man

Description

@Ball-Man

Describe the feature or idea you want to propose

The deep learning side of the toolkit has great ergonomics, bringing sklearn's API and state of the art models close together. However, the Tensorflow dependency is quite inconvenient, forcing an extra Python version constraint on the toolkit, and forcing users on an arbitrary framework.

Describe your proposed solution

The toolkit is actually mainly built on top of the high level Keras API, with minimal pure Tensorflow usage. The latest major release of Keras, Keras 3, leaves the high level API intact, but is backend agnostic (compatible backends include TF, Torch, Jax). Most of the existing DL algorithms in aeon could easily be adapted to this new API by simply replacing the tf.keras calls with pure keras ones. User could then decide which of the supported backends to use based on what is more convenient for their project.

As a proof of concept, I adapted one of the simple DL algorithms (TimeCNNClassifier) to work with Keras 3. Here is the branch: https://github.com/Ball-Man/aeon/tree/keras3_concept
With minimal to no changes, relevant unit tests (specific to this classifier) are working as intended. As a qualitative approach, from the same branch, here you can see the very first example in the deep learning classification notebook working as intended (just the first cell, where Time CNN is used): https://github.com/Ball-Man/aeon/blob/keras3_concept/examples/classification/deep_learning.ipynb

The example works with Python 3.13 and uses Torch as backend.

Describe alternatives you've considered, if relevant

No response

Additional context

Feasibility

As a feasibility study, I inspected all modules of the aeon toolkit, looking for potential obstacles. Here is what I found out from a shallow search:

  • All network definitions (aeon.networks), aside from weight normalization, seem to be adaptable by immediate replacement of the tf.keras calls.
  • All DL classification models (aeon.classification.deep_learning) and regression models (aeon.regression.deep_learning) seem to be adaptable by immediate replacement of the tf.keras calls.
  • All DL clustering models (aeon.clustering.deep_learning). aside from ae fcn and ae resnet, seem to be adaptable by immediate replacement of the tf.keras calls. This is despite the fact that the network definitions of ae fcn and resnet can easily be adapted.
  • Rocket GPU can not immediately be adapted by replacing the tf calls. This would require using the new numpy-like interface from Keras 3, keras.ops.
  • Some tests and notebooks would require keras.ops or other minor changes (e.g. aeon.networks.tests.test_all_networks).
  • All the other problematic modules (weight normalization, ae fcn clustering and ae resnet clustering) should be adatpable using keras.ops.

I believe the value of such an update would be immense. I can work on it if/when needed.

edit: title formatting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    deep learningDeep learning relateddependenciesThis issue or PR is related to dependencies of aeonenhancementNew feature, improvement request or other non-bug code enhancementnetworksNetworks package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions