以下代码抛出一个TypeError
import tensorflow as tf
h=tf.int32(6)
错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'DType' object is not callable
为什么?
最佳答案
tf.int32
对象不是构造函数。如果要创建类型为 tf.int32
且值为 6
的张量,则应使用 tf.constant()
,如下:
h = tf.constant(6, dtype=tf.int32)
关于python - 类型错误 : 'DType' object is not callable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48043359/