tf.cast()函数是将tensorflow中数据类型转换为其他类型的函数:cast(x, dtype, name=None)
x = True
y = 3
z = tf.cast([x, y], dtype=tf.float32)
with tf.Session() as sess:
print(sess.run(z))
输出结果:
[1. 3.]
Process finished with exit code 0
``
tf.cast()函数将整型数据转换为float32类型,也可以将BOOL类型转为0或者1输出