[英]How to add Dropout in Keras functional model?
假設我在Keras有一個LSTM層,如下所示:
x = Input(shape=(input_shape), dtype='int32')
x = LSTM(128,return_sequences=True)(x)
現在我嘗試使用以下方法將Dropout添加到此圖層:
X = Dropout(0.5)
但是這給出了錯誤,我假設上面的行正在重新定義X而不是向它添加Dropout。 如何解決這個問題?
只需添加x = Dropout(0.5)(x)
如下所示:
x = Input(shape=(input_shape), dtype='int32')
x = LSTM(128,return_sequences=True)(x)
x = Dropout(0.5)(x)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.