在Tensorflow中输入LSTM图层

时间:2018-03-06 16:36:55

标签: python tensorflow lstm

如何输出"完全连接的"层到Tensorflow中的LSTM层。我正在尝试以下代码:

hidden1 = fully_connected(X, n_hidden1, scope="hidden1")
hidden2 = fully_connected(hidden1, n_hidden2, scope="hidden2")
hidden3 = fully_connected(hidden2, n_hidden3, scope="hidden3")
lstm=tf.contrib.cudnn_rnn.CudnnCompatibleLSTMCell(n_lstm)
initial_state = lstm.zero_state(batch_size, tf.float32)
lstm_outputs, final_state = tf.nn.dynamic_rnn(lstm, hidden3, 
initial_state=initial_state)
output = fully_connected(lstm, n_outputs,scope="outputs",activation_fn=None)

LSTM层需要3D张量作为输入,例如(batch_size,max_time,num_features)但输出" fully_connected"图层是一维张量。

如何实现神经网络,其中LSTM层的输入是"完全连接的" Tensorflow中的图层?

感谢帮助!!!

0 个答案:

没有答案