San*_*ram 3 lstm tensorflow recurrent-neural-network
我可以创建一个具有两层LSTM的RNN网络,如下所示:
lstm_cell1 = tf.nn.rnn_cell.BasicLSTMCell(50)
lstm_cell2 = tf.nn.rnn_cell.BasicLSTMCell(100)
lstm_net = tf.nn.rnn_cell.MultiRNNCell([lstm_cell1, lstm_cell2])
Run Code Online (Sandbox Code Playgroud)
但是现在我还希望在每个lstm单元格之后包含dropout图层.就像是,
tf.nn.rnn_cell.MultiRNNCell([tf.nn.dropout(lstm_cell1, 0.8), tf.nn.dropout(lstm_cell2, 0.8)])
Run Code Online (Sandbox Code Playgroud)
我该如何实现这一目标?
小智 6
lstm_cell = tf.contrib.rnn.BasicLSTMCell(n_hidden_units)
lstm_dropout = tf.contrib.rnn.DropoutWrapper(lstm_cell,input_keep_prob=keep_prob, output_keep_prob=keep_prob)
lstm_layers = tf.contrib.rnn.MultiRNNCell([lstm_dropout]* 2)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3812 次 |
| 最近记录: |