[英]Dropout_U and Dropout_W is not defined in LSTM model
我正面臨這個錯誤
NameError: name 'Dropout_U' is not defined
通過創建 LSTM 模型
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())
你能幫我克服這個問題嗎?
使用的語法已經過時, Dropout_U
已更改為recurrent_dropout
。 Dropout_W
就是Dropout
。
如果您要更換Dropout_U
與recurrent_dropout
,使你LSTM層的一部分它應該工作。 只需將Dropout_W
層更改為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())
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.