如何得到十的类型

2024-04-25 22:59:39 发布

您现在位置:Python中文网/ 问答频道 /正文


Tags: python
2条回答

可以使用get_shape()获得tensorflow变量的形状。

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

可以使用dtype属性获取tensorflow变量的类型。

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

可以使用dtype的as_numpy_dtype属性从tf.dtype转换为numpy dtype

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

得到你能做的类型

x.dtype

相关问题 更多 >