Skip to content

Conversation

mehtamansi29
Copy link
Collaborator

timeseries_classification_transformer model creation data_format="channels_last" is giving less model parameters and degrades accuracy. Update example with data_format="channels_first". Fixes #20627


x = layers.GlobalAveragePooling1D(data_format="channels_last")(x)
print(f"Transformer Encoder: {x}")
x = layers.GlobalAveragePooling1D(data_format="channels_first")(x)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect unfortunately? We should be pooling on the time dimension.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fchollet - As per code example earlier data_format="channels_last" reduces the model parameter and accuracy degradation on GPU in latest keras. data_format="channels_first" in pooling also reduce the number of time steps in same GPU environment and get good accuracy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GlobalAveragePooling1D data_format Question
3 participants