网站首页 文章专栏 tensorflow lstm原理与代码从头构建
tensorflow lstm原理与代码从头构建
”`python
lstm_cell = tf.contrib.rnn.BasicLSTMCell(n_hidden_units, forget_bias=1.0, state_is_tuple=True)
init_state = lstm_cell.zero_state(batch_size, dtype=tf.float32) # 初始化全零 state
outputs, final_state = tf.nn.dynamic_rnn(lstm_cell, X_in, initial_state=init_state, time_major=False)
outputs size: [batch_size, max_time, cell_state_size]
final_state[1] size: [batch_size, cell_state_size]
”`