I am facing this error
NameError: name 'Dropout_U' is not defined
by creating an LSTM model
embed_dim = 128
lstm_out = 200
batch_size = 32
model = Sequential()
model.add(Embedding(2500, embed_dim,input_length = X.shape[1]))
model.add(Dropout(0.2))
model.add(LSTM(lstm_out))
model.add(Dropout_U(0.2))
model.add(Dropout_W(0.2))
model.add(Dense(2,activation='sigmoid'))
model.compile(loss = 'categorical_crossentropy', optimizer='adam',metrics = ['accuracy'])
print(model.summary())
Can you help me overcome this problem?
The syntax used is outdated, Dropout_U
has been changed to recurrent_dropout
. Dropout_W
is simply Dropout
.
If you replace Dropout_U
with recurrent_dropout
and make it part of your LSTM layer it should work. Simply change the Dropout_W
layer to Dropout
.
embed_dim = 128
lstm_out = 200
batch_size = 32
model = Sequential()
model.add(Embedding(2500, embed_dim,input_length = X.shape[1]))
model.add(Dropout(0.2))
model.add(LSTM(lstm_out, recurrent_dropout=0.2))
model.add(Dropout(0.2))
model.add(Dense(2,activation='sigmoid'))
model.compile(loss = 'categorical_crossentropy', optimizer='adam',metrics = ['accuracy'])
print(model.summary())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.