Reputation: 186
Following code throws a TypeError
import tensorflow as tf
h=tf.int32(6)
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'DType' object is not callable
Why?
Upvotes: 2
Views: 6639
Reputation: 126154
The tf.int32
object is not a constructor. If you want to create a tensor of type tf.int32
with value 6
, you should use tf.constant()
, as follows:
h = tf.constant(6, dtype=tf.int32)
Upvotes: 6