TF的使用

一、tf.cast

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

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.global_variables_initializer() )
print(sess.run(b))
#[ True False False  True  True]

猜你喜欢

转载自www.cnblogs.com/always-fight/p/10056652.html
今日推荐