一、函數 tf.cast()
cast( x, dtype, name=None )
將x的數據格式轉化成dtype.例如,原來x的數據格式是bool,
那么將其轉化成float以后,就能夠將其轉化成0和1的序列。反之也可以
二、例子
【code】
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]
------------------------------------------------------------
參考:
- http://blog.csdn.net/luoganttcc/article/details/70315538
- https://www.tensorflow.org/api_docs/python/tf/cast