How to get the type of tensor

I am looking for something similar to the effects of x.get_shape () which gives type x. If there is no function, how to do it?

+4
source share
2 answers

You can use get_shape () to get the form of the tensorflow variable.

>>> x = tf.Variable(tf.random_normal([256, 100]))
>>> x.get_shape()
(256, 100)

You can use the dtype property to get the type of the tensorflow variable.

>>> x = tf.Variable(tf.random_normal([256, 100]))
>>> x.dtype
<dtype: 'float32_ref'>

You can use the as_numpy_dtype dtype property to convert from tf.dtype to numpy dtype .

>>> x = tf.Variable(tf.random_normal([256, 100]))
>>> x.dtype.as_numpy_dtype
<class 'numpy.float32'>
+12
source

To get the type you can do

x.dtype
+7
source

Source: https://habr.com/ru/post/1672133/


All Articles