Class DType
定义在: tensorflow/python/framework/dtypes.py
.
中文版:https://www.w3cschool.cn/tensorflow_python/tensorflow_python-d6x22e0f.html
英文指南: Building Graphs > Tensor types
要查看 tf.Tensor
的数据类型,请使用 Tensor.dtype
属性。
用 python 对象创建 tf.Tensor
时,可以选择指定数据类型。
如果不指定数据类型,TensorFlow 会将 Python 整数转型为 tf.int32
,并将 python 浮点数转型为 tf.float32
。
此外,TensorFlow 使用 Numpy 在转换至数组时使用的相同规则。
Represents the type of the elements in a Tensor
.
The following DType
objects are defined:
tf.float16
: 16-bit half-precision floating-point.tf.float32
: 32-bit single-precision floating-point.tf.float64
: 64-bit double-precision floating-point.tf.bfloat16
: 16-bit truncated floating-point.tf.complex64
: 64-bit single-precision complex.tf.complex128
: 128-bit double-precision complex.tf.int8
: 8-bit signed integer.tf.uint8
: 8-bit unsigned integer.tf.uint16
: 16-bit unsigned integer.tf.uint32
: 32-bit unsigned integer.tf.uint64
: 64-bit unsigned integer.tf.int16
: 16-bit signed integer.tf.int32
: 32-bit signed integer.tf.int64
: 64-bit signed integer.tf.bool
: Boolean.tf.string
: String.tf.qint8
: Quantized 8-bit signed integer.tf.quint8
: Quantized 8-bit unsigned integer.tf.qint16
: Quantized 16-bit signed integer.tf.quint16
: Quantized 16-bit unsigned integer.tf.qint32
: Quantized 32-bit signed integer.tf.resource
: Handle to a mutable resource.tf.variant
: Values of arbitrary types.
In addition, variants of these types with the _ref
suffix are defined for reference-typed tensors.
此外, 还为引用类型的张量定义了具有 _ref 后缀的这些类型的变体。
The tf.as_dtype()
function converts numpy types and string type names to a DType
object.
该 tf.as_dtype() 函数将 numpy 类型和字符串类型名称转换为DType对象。