tf.cast数据格式转换函数

#cast(x, dtype, name=None) 
#将x的数据格式转化成dtype.
import tensorflow as tf

a = tf.Variable([1,0,0,1,1])
b = tf.cast(a,dtype=tf.bool)
sess = tf.Session()
sess.run(tf.initialize_all_variables())
print(sess.run(b))
#[ True False False  True  True]

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_33595571/article/details/84849906