【问题标题】:Why do tensorflow Variables in outputs of dynamic (or static) rnn with lstm cell has plus-one dimensionality?为什么带有 lstm 单元的动态(或静态)rnn 输出中的张量流变量具有加一维?
【发布时间】:2018-01-28 05:32:19
【问题描述】:

我的问题是关于元素动态或静态 rnn 输出的维度。

nlu_input = tf.placeholder(tf.float32, shape=[4,1607,1])
cell = tf.nn.rnn_cell.BasicLSTMCell(80)
outts, states = tf.nn.dynamic_rnn(cell=cell, inputs=nlu_input, dtype=tf.float32)

然后 tf.gloabal_valiables() 返回以下列表。

[<tf.Variable 'rnn/basic_lstm_cell/kernel:0' shape=(81, 320) dtype=float32_ref>,<tf.Variable 'rnn/basic_lstm_cell/bias:0' shape=(320,) dtype=float32_ref>]

我期望 tf.Variable 'rnn/basic_lstm_cell/kernel:0' shape=(80, 320),因为 320 = 4*80 并且单元数是 80。

为什么内核的维数会增加?

【问题讨论】:

    标签: python tensorflow neural-network lstm rnn


    【解决方案1】:

    根据tensorflow实现:BasicLSTMCell source codekernel 的形状是[input_depth + h_depth, 4 * num_units],其中input_depth 是您的输入向量维度,h_depth 是您的隐藏单元数。所以你的内核形状是[1 + 80, 4 * 80]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-10
      • 2018-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-25
      相关资源
      最近更新 更多