短小精悍算例:TensorFlow中使用cast()函数转换数据类型

import tensorflow as tf
import numpy as np
A = tf.placeholder(dtype=tf.float32, shape=[2, 2])
B = tf.cast(A, tf.float64)
print(A.dtype,B.dtype)

输出结果:
<dtype: 'float32'> <dtype: 'float64'>

A是32位浮点型,转换为B后是64位浮点型。

猜你喜欢

转载自blog.csdn.net/weixin_39464400/article/details/106141410
今日推荐