aeon icon indicating copy to clipboard operation
aeon copied to clipboard

[ENH] Implement AEAttentionBiGRUNetwork

Open aadya940 opened this issue 1 year ago • 15 comments

Implements Attention Bidirectional Gated Recurrent Unit based Auto Encoder .

aadya940 avatar Jun 05 '24 14:06 aadya940

Thank you for contributing to aeon

I have added the following labels to this PR based on the title: [ $\color{#FEF1BE}{\textsf{enhancement}}$ ]. I have added the following labels to this PR based on the changes made: [ $\color{#379E11}{\textsf{networks}}$ ]. Feel free to change these if they do not properly represent the PR.

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, any trivial fixes will automatically be pushed to your PR unless it is a draft.

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

aeon-actions-bot[bot] avatar Jun 05 '24 14:06 aeon-actions-bot[bot]

@hadifawaz1999 How can we use the Keras Subclassing API in this case, since the tests that don't have tensorflow will fail?

aadya940 avatar Jun 06 '24 06:06 aadya940

See the Hydra transformation for ideas, there is ways to get around it. Not sure you can do local classes in Python? Probably dont want to either way 🙂

MatthewMiddlehurst avatar Jun 06 '24 09:06 MatthewMiddlehurst

@MatthewMiddlehurst Thanks :-)

aadya940 avatar Jun 06 '24 09:06 aadya940

@hadifawaz1999 What will change if we add support for temporal_latent_space in this? Do we apply the Attention and self._gate if temporal_latent_space is True since self._gate will Flatten the input tensor and convert it from 3 Dimensions to 2 Dimension and the output will no longer be temporal?

aadya940 avatar Jun 06 '24 10:06 aadya940

See the Hydra transformation for ideas, there is ways to get around it. Not sure you can do local classes in Python? Probably dont want to either way 🙂

yup should work like we have in hydra

hadifawaz1999 avatar Jun 06 '24 10:06 hadifawaz1999

@hadifawaz1999 What will change if we add support for temporal_latent_space in this? Do we apply the Attention and self._gate if temporal_latent_space is True since self._gate will Flatten the input tensor and convert it from 3 Dimensions to 2 Dimension and the output will no longer be temporal?

let me check the architecture and get back to you

hadifawaz1999 avatar Jun 06 '24 10:06 hadifawaz1999

@hadifawaz1999 What will change if we add support for temporal_latent_space in this? Do we apply the Attention and self._gate if temporal_latent_space is True since self._gate will Flatten the input tensor and convert it from 3 Dimensions to 2 Dimension and the output will no longer be temporal?

let me check the architecture and get back to you

hadifawaz1999 avatar Jun 06 '24 10:06 hadifawaz1999

sorry closed it by mistake miss clicking with my mouse :)

hadifawaz1999 avatar Jun 06 '24 10:06 hadifawaz1999

if i understand correctly, the number of params for RNN layers depend on the batch size right ? as it depends on x.shape[0]

hadifawaz1999 avatar Jun 06 '24 10:06 hadifawaz1999

Yep, that's what I understood.

aadya940 avatar Jun 06 '24 10:06 aadya940

@hadifawaz1999 Can we really parametrize the number of layers here? Since, after the input passes through a Dense layers , its dimensions decrease from 3D to 2D and hence, we cant pass it to the next GRU layer. Also, the implementation here uses just 1 layer in the encoder, as well as the decoder: https://github.com/blafabregue/TimeSeriesDeepClustering/blob/main/networks/attention_rnn.py

aadya940 avatar Jun 08 '24 16:06 aadya940

Could we just expand the dims of the tensor after each dense layer as follows?

if not (i == self.n_layers_encoder - 1):
   x = tf.expand_dims(x, -1)

aadya940 avatar Jun 08 '24 21:06 aadya940

should merge main here too @aadya940

hadifawaz1999 avatar Aug 02 '24 19:08 hadifawaz1999

#1962

aadya940 avatar Aug 13 '24 10:08 aadya940