参考 tensorflow数据类型转换 - 云+社区 - 腾讯云
tensorflow支持14种不同的类型,主要包括:
将张量强制转换为bfloat16类型。(deprecated)
- tf.to_bfloat16(
- x,
- name='ToBFloat16'
- )
参数:
返回值:
可能产生的异常:
TypeError: If x cannot be cast to the bfloat16.将张量转换为类型为complex128的张量。(deprecated)
- tf.to_complex128(
- x,
- name='ToComplex128'
- )
警告:不推荐使用此函数。它将在未来的版本中被删除。更新说明:使用tf。演员代替。
参数:
返回值:
可能产生的异常:
TypeError: If x cannot be cast to the complex128.将张量转换为complex64类型。(deprecated)
- tf.to_complex64(
- x,
- name='ToComplex64'
- )
警告:不推荐使用此函数。它将在未来的版本中被删除。更新说明:使用tf。演员代替。
参数:
返回值:
可能产生的异常:
TypeError: If x cannot be cast to the complex64.将张量强制转换为float64类型。(deprecated)
- tf.to_double(
- x,
- name='ToDouble'
- )
警告:不推荐使用此函数。它将在未来的版本中被删除。更新说明:使用tf。演员代替。
参数:
返回值:
可能产生的异常:
TypeError: If x cannot be cast to the float64.将张量强制转换为float32类型。(deprecated)
- tf.to_float(
- x,
- name='ToFloat'
- )
参数:
返回值:
可能产生的异常:
TypeError: If x cannot be cast to the float32.将张量转换为int32类型。(deprecated)
- tf.to_int32(
- x,
- name='ToInt32'
- )
参数:
返回值:
可能产生的异常:
TypeError: If x cannot be cast to the int32.将张量转换为int64类型。(deprecated)
- tf.to_int64(
- x,
- name='ToInt64'
- )
参数:
返回值:
可能产生的异常:
TypeError: If x cannot be cast to the int64.