Tensorflow:AttributeError:'tuple'对象没有属性'dtype'

时间:2017-11-21 02:56:47

标签: python tensorflow

这里发生了什么?

代码:

def text_model(text, memory):
    import tensorflow as tf

    tf.logging.set_verbosity(tf.logging.INFO)

    # Text parsing.
    lastLayer = tf.convert_to_tensor([text, memory])
    for i in range(0, 200):
        thinking = tf.layers.dense(inputs = lastLayer, units = pow(10, 9), activation = tf.nn.relu)

        lastLayer = thinking, [32000, -1]
    response = tf.layers.dense(inputs = lastLayer, units = pow(10, 4), activation = tf.nn.relu)
    memory = tf.reshape(tf.convert_to_tensor([lastLayer, response]), [-1])

    return [response, memory]

textList = text_model([1], [1])

print(textList)

错误报告:

AttributeError: 'tuple' object has no attribute 'dtype'

其他获得相同错误的人似乎在完全不同的环境中获得它。为什么在此上下文中发生此错误,我该如何解决?

谢谢。 :)

1 个答案:

答案 0 :(得分:0)

此行将lastLayer设置为等于元组:

lastLayer = thinking, [32000, -1]

for循环第二次执行时,它将尝试访问lastLayer作为张量,但您已将其转换为元组。所以你得到了错误。