How to get the type of a Tensor?

后端 未结 2 2056
心在旅途
心在旅途 2021-02-12 12:04

I\'m looking for something similar to the effects of:

x.get_shape()

that will give the type of x. Is there is any function for thi

2条回答
  •  情深已故
    2021-02-12 12:34

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

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

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

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

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

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

提交回复
热议问题