一、函数 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]

------------------------------------------------------------

参考:

  1. http://blog.csdn.net/luoganttcc/article/details/70315538
  2. https://www.tensorflow.org/api_docs/python/tf/cast

相关文章:

  • 2022-03-02
  • 2021-10-10
  • 2021-10-23
  • 2021-09-22
  • 2021-12-02
  • 2021-10-06
  • 2021-12-13
  • 2021-05-26
猜你喜欢
  • 2021-09-28
  • 2022-12-23
  • 2021-12-14
  • 2021-12-19
  • 2021-11-13
  • 2021-12-13
  • 2021-07-21
相关资源
相似解决方案