tf.cast()类型转换函数
生活随笔
收集整理的這篇文章主要介紹了
tf.cast()类型转换函数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
tf.cast(x, dtype, name=None)
參數
- x:輸入
- dtype:轉換目標類型
- name:名稱
返回:Tensor
例子:
import tensorflow as tfa = [1,0,1,0] b = [1,2,3,4] c = [True, True, False] d = tf.cast(a, dtype=bool) e = tf.cast(b, dtype=bool) f = tf.cast(c, dtype=tf.float32) sess = tf.InteractiveSession() print(sess.run(d)) # [ True False True False] print(sess.run(e)) # [ True True True True] print(sess.run(f)) # [1. 1. 0.]?
總結
以上是生活随笔為你收集整理的tf.cast()类型转换函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 工业机器人的控制方式
- 下一篇: win10下TensorFlow-GPU