![](/img/trans.png)
[英]ValueError: Tensor conversion requested dtype int32 for Tensor with dtype float32 - LSTM Implementation( tensorflow 2.0.0)
[英]tensorflow . Tensor(“Mul:0”, shape=(), dtype=int32)
我有以下python文件,当我运行它时,它显示错误,请问如何解决?
-----------------------
import tensorflow as tf
x1 = tf.constant(5)
x2 = tf.constant(6)
result = tf.multiply(x1,x2)
print(result)
--------------------
error:
Tensor("Mul:0", shape=(), dtype=int32)
到目前为止,您要做的就是创建一个(非常简单的)计算图。 为了实际执行任何计算,您需要一个会话并使用run方法。
我强烈建议您阅读https://www.tensorflow.org/get_started/get_started以了解tensorflow的计算模型。
import tensorflow as tf
x1 = tf.constant(5)
x2 = tf.constant(6)
result = tf.multiply(x1,x2)
sess = tf.Session()
sess.run(result)
[编辑]我还应该补充一点,您看到的输出根本不是错误,它只是您创建的张量的字符串表示形式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.