tf.cast

cast(x, dtype, name=None)
将x的数据格式转化成dtype.例如,原来x的数据格式是bool,
那么将其转化成float以后,就能够将其转化成0和1的序列。反之也可以

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]

https://blog.csdn.net/luoganttcc/article/details/70315538?utm_source=copy

猜你喜欢

转载自blog.csdn.net/qq_37701443/article/details/82855470