Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output of softmax GRU and LSTM layers does not add up to 1 #6255

Closed
louisabraham opened this issue Apr 14, 2017 · 2 comments
Closed

Output of softmax GRU and LSTM layers does not add up to 1 #6255

louisabraham opened this issue Apr 14, 2017 · 2 comments

Comments

@louisabraham
Copy link

import numpy as np
from keras.models import *
from keras.layers import *
m = Sequential()
m.add(LSTM(3, input_shape=(3,2), activation='softmax'))
print(m.predict(np.random.rand(5,3,2)).sum(axis=-1))

[ 0.56759441  0.59162366  0.57279199  0.52342385  0.54326206]

Works fine with Dense or SimpleRNN.
If this is normal, it should be specified in the doc, because it is NOT logical…

@joelthchao
Copy link
Contributor

joelthchao commented Apr 15, 2017

Yes, this is somehow misleading. Activation here is directly apply on each hidden unit. However, we won't use LSTM in this way. Usually, we do it by:

m.add(LSTM(hidden_unit, input_shape=(3,2)))
m.add(Dense(3, activation='softmax')) 

@stale stale bot added the stale label Jul 14, 2017
@stale
Copy link

stale bot commented Jul 14, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.

@stale stale bot closed this as completed Aug 13, 2017
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

No branches or pull requests

2 participants