小编Ben*_*iBB的帖子

如何在LSTM中实现Tensorflow批量规范化

我目前的LSTM网络看起来像这样.

rnn_cell = tf.contrib.rnn.BasicRNNCell(num_units=CELL_SIZE)
init_s = rnn_cell.zero_state(batch_size=1, dtype=tf.float32)  # very first hidden state
outputs, final_s = tf.nn.dynamic_rnn(
    rnn_cell,              # cell you have chosen
    tf_x,                  # input
    initial_state=init_s,  # the initial hidden state
    time_major=False,      # False: (batch, time step, input); True: (time step, batch, input)
)

# reshape 3D output to 2D for fully connected layer
outs2D = tf.reshape(outputs, [-1, CELL_SIZE])
net_outs2D = tf.layers.dense(outs2D, INPUT_SIZE)

# reshape back to 3D
outs = tf.reshape(net_outs2D, [-1, TIME_STEP, INPUT_SIZE])
Run Code Online (Sandbox Code Playgroud)

通常,我申请tf.layers.batch_normalization批量标准化.但我不确定这是否适用于LSTM网络.

b1 = …
Run Code Online (Sandbox Code Playgroud)

python neural-network lstm tensorflow rnn

19
推荐指数
1
解决办法
1513
查看次数

标签 统计

lstm ×1

neural-network ×1

python ×1

rnn ×1

tensorflow ×1