我想将形状为(1,70,70)的隐藏层的输出张量馈送到lstm层。 lstm层具有70个单位和1个时间步。如何调整张量以使其与张量流中的lstm输入兼容。 input_layer = layer.dense(self.xs,70,activation ='relu',kernel_initializer ='random_uniform')
hidden1 = layer.dense(input_layer, 70, activation='relu',
kernel_initializer='random_uniform')
hidden2 = layer.dense(hidden1, 70, activation='relu',
kernel_initializer='random_uniform')
hidden3 = layer.dense(hidden2, 70, activation='relu',
kernel_initializer='random_uniform')
hidden4 = layer.dense(hidden3, 70, activation='relu',
kernel_initializer='random_uniform')
lstm_cell_1 = tf.contrib.rnn.BasicLSTMCell(self.num_units, forget_bias=1.0, state_is_tuple=True)
lstm_cell_2 = tf.contrib.rnn.BasicLSTMCell(self.num_units, forget_bias=1.0, state_is_tuple=True)
lstm_cell = tf.contrib.rnn.MultiRNNCell([lstm_cell_1, lstm_cell_2], state_is_tuple=True)
initial_state = lstm_cell.zero_state(self.batch_size, dtype=tf.float32)
with tf.variable_scope('lstm1'):
outputs, final_state = tf.nn.dynamic_rnn(lstm_cell, hidden4, initial_state=initial_state)