【问题标题】:Tensorflow rnn: name 'seq2seq' is not definedTensorflow rnn:名称'seq2seq'未定义
【发布时间】:2017-04-10 17:51:30
【问题描述】:

我正在尝试这个笔记本: https://github.com/sjchoi86/Tensorflow-101/blob/master/notebooks/char_rnn_sample_tutorial.ipynb

我对这行 In[6] 有问题:

outputs, final_state = seq2seq.rnn_decoder(inputs, istate, cell, loop_function=None, scope='rnnlm')

我得到这个错误:

NameError: name 'seq2seq' is not defined

我使用的是 tensorflow 1.0.1。我试过了

tf.contrib.seq2seq

但我收到错误:

AttributeError: 'module' object has no attribute 'rnn_decoder'

我认为这是 tensorflow 1.0.1 中新实现的 rnn 网络的问题,但我不知道如何解决。

【问题讨论】:

    标签: python tensorflow attributeerror lstm recurrent-neural-network


    【解决方案1】:

    因为seq2seq 已移至tf.contrib.legacy_seq2seq。您应该将此行更改为:

    outputs, final_state = tf.contrib.legacy_seq2seq.rnn_decoder(inputs, istate, cell, loop_function=None, scope='rnnlm')
    

    【讨论】:

    • 现在,这一行出现另一个错误: output = tf.reshape(tf.concat(1, outputs),[-1, rnn_size] ) 错误消息: TypeError: Expected int32, got列表包含类型为“_Message”的张量。
    • @Aggounix 从 tf 0.12 开始,tf.concat 改变了它采用的参数顺序。我认为output = tf.reshape(tf.concat(outputs, 1),[-1, rnn_size] ) 应该可以吗?
    • @Aggounix 我认为他们对其进行了更改以使其与numpy.concatenate((arr1, arr2, ...), axis)保持一致
    猜你喜欢
    • 1970-01-01
    • 2018-11-19
    • 1970-01-01
    • 1970-01-01
    • 2016-09-06
    • 2018-03-11
    • 1970-01-01
    • 1970-01-01
    • 2021-05-12
    相关资源
    最近更新 更多