keras-team / keras-io

Keras documentation, hosted live at keras.io
Apache License 2.0
2.69k stars 2.01k forks source link

Timeseries Classification Transformer: Last -> First #1876

Open duck-bongos opened 1 month ago

duck-bongos commented 1 month ago

Issue Type

Documentation Bug

Source

source

Keras Version

2.13.1

Custom Code

No

OS Platform and Distribution

Google Colab

Python version

Python 3

GPU model and memory

N/A

Current Behavior?

The tutorial's (https://keras.io/examples/timeseries/timeseries_classification_transformer/) got a line in it that doesn't match the output network example. This is the line in the 3rd code block:

...
x = layers.GlobalAveragePooling1D(data_format="channels_last")(x)
...

I copied and pasted the tutorial to play around with and found it returns a network output different than what is expected in the tutorial.

Screen Shot 2024-05-26 at 4 11 57 PM

When I changed the line to

...
x = layers.GlobalAveragePooling1D(data_format="channels_first")(x)
...

The network parameters lined up with the tutorial!

Screen Shot 2024-05-26 at 4 11 26 PM

Standalone code to reproduce the issue or tutorial link

It's in the tutorial :)

Relevant log output

No additional log output
chunduriv commented 3 weeks ago

@duck-bongos,

As mentioned here, the input should be (batch, time, features) and the output should be (batch, features). So it seems "channels_last" is correct.

github-actions[bot] commented 1 week ago

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.