代碼:
input1 = tf.placeholder(tf.types.float32)
input2 = tf.placeholder(tf.types.float32)
output = tf.mul(input1, input2)
with tf.Session()as sess:
print (sess.run([output], feed_dict={input:[7.], input2:[2.]}))
報錯1:
AttributeError: module 'tensorflow' has no attribute 'types'
解決辦法:
input1 = tf.placeholder(tf.float32)
input2 = tf.placeholder(tf.float32)
報錯2:
AttributeError: module 'tensorflow' has no attribute 'mul'
解決辦法:
output = tf.multiply(input1, input2)
報錯3:
Cannot interpret feed_dict key as Tensor: Can not convert a method into a Tensor.
解決辦法:
print sess.run([output], feed_dict={input1:[7.], input2:[2.]})
轉自點擊打開鏈接