以下代码抛出一个 TypeError
import tensorflow as tf
h=tf.int32(6)
Run Code Online (Sandbox Code Playgroud)
错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'DType' object is not callable
Run Code Online (Sandbox Code Playgroud)
为什么?
该tf.int32
对象不是构造函数。如果要创建类型tf.int32
为 value的张量6
,则应使用tf.constant()
,如下所示:
h = tf.constant(6, dtype=tf.int32)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4653 次 |
最近记录: |