【发布时间】:2019-06-28 06:23:25
【问题描述】:
我正在尝试弄清楚功能齐全的 python 代码是如何工作的。一个块使用 tensorflow 创建一个 LSTM 单元。我不知道如何解释下面评论指定的行。
def get_lstm_weights(n_hidden, forget_bias, dim, scope="rnn_cell"):
# Create LSTM cell
cell = tf.contrib.rnn.LSTMCell(num_units = n_hidden, reuse=None, forget_bias = forget_bias)
#--------------------------------------
# I DO NOT UNDERSTAND THE NEXT LINE
cell(tf.zeros([1, dim +1]), (tf.zeros([1, n_hidden]),tf.zeros([1, n_hidden])), scope=scope)
# -------------------------------------
cell = tf.contrib.rnn.LSTMCell(num_units = n_hidden, reuse=True, forget_bias = forget_bias)
# Create output weights
weights = {
'W_1': tf.Variable(tf.truncated_normal([n_hidden, dim], stddev=0.05)),
'b_1': tf.Variable(0.1*tf.ones([dim])),
}
return cell, weights
【问题讨论】:
标签: python tensorflow lstm