Skip to content

Conversation

copybara-service[bot]
Copy link

PR #18105: [Add Feature] - Warn user if softmax usage is wrong

Imported from GitHub PR #18105

This is a utility function to check if the usage of softmax makes sense (new users make this mistake a lot). Applying softmax on a single neuron will make the model output ones everytime, there are too many Stackoverflow posts about this.

In order to see this in action, please check the gist.

This applies for any other layers (Conv2D etc.) where the applied axis (axis=-1 default) of softmax has only one unit.
Copybara import of the project:

--
90c95b1 by Kaan Bıçakcı [email protected]:

Add last layer activation check for softmax

--
1cedb20 by Kaan Bıçakcı [email protected]:

Split logic for sequential and functional models

--
529f968 by Kaan Bıçakcı [email protected]:

Add tests for _check_last_layer_activation

--
d1acddb by Kaan Bıçakcı [email protected]:

Update sequential check

--
8363016 by Kaan Bıçakcı [email protected]:

Update tests, logic and reformatting

--
ebf16c3 by Kaan Bıçakcı [email protected]:

Update tests and the logic

--
afc156a by Kaan Bıçakcı [email protected]:

Make validate_softmax_activation experimental

Merging this change closes #18105

FUTURE_COPYBARA_INTEGRATE_REVIEW=#18105 from Frightera:last_layer_softmax_warn afc156a

Imported from GitHub PR #18105

This is a utility function to check if the usage of softmax makes sense (new users make this mistake a lot). Applying softmax on a single neuron will make the model output ones everytime, there are too many Stackoverflow posts about this.

In order to see this in action, please check [the gist](https://colab.research.google.com/gist/Frightera/fdcec020fff6ee9521ae2fd3eaed774d/checksoftmaxlastlayer.ipynb).

This applies for any other layers (Conv2D etc.) where the applied axis (axis=-1 default) of softmax has only one unit.
Copybara import of the project:

--
90c95b1 by Kaan Bıçakcı <[email protected]>:

Add last layer activation check for softmax

--
1cedb20 by Kaan Bıçakcı <[email protected]>:

Split logic for sequential and functional models

--
529f968 by Kaan Bıçakcı <[email protected]>:

Add tests for _check_last_layer_activation

--
d1acddb by Kaan Bıçakcı <[email protected]>:

Update sequential check

--
8363016 by Kaan Bıçakcı <[email protected]>:

Update tests, logic and reformatting

--
ebf16c3 by Kaan Bıçakcı <[email protected]>:

Update tests and the logic

--
afc156a by Kaan Bıçakcı <[email protected]>:

Make validate_softmax_activation experimental

Merging this change closes #18105

FUTURE_COPYBARA_INTEGRATE_REVIEW=#18105 from Frightera:last_layer_softmax_warn afc156a
PiperOrigin-RevId: 533267082
@copybara-service copybara-service bot closed this Jun 26, 2023
@copybara-service copybara-service bot deleted the test_533267082 branch June 26, 2023 22:28
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.

1 participant