官术网_书友最值得收藏!

Casting a tensor to another (tensor) datatype

TensorFlow variables of one type may be cast (coerced) to another type. More details may be found at https://www.tensorflow.org/api_docs/python/tf/cast.

Take the following example:

i = tf.cast(t1, dtype=tf.int32) # 42
i

The output will be as follows:

<tf.Tensor: id=116, shape=(), dtype=int32, numpy=42>

 

With truncation, it would be as follows:

j = tf.cast(tf.constant(4.9), dtype=tf.int32) # 4
j

The output will be as follows:

<tf.Tensor: id=119, shape=(), dtype=int32, numpy=4>
主站蜘蛛池模板: 井陉县| 绍兴县| 攀枝花市| 清河县| 那曲县| 宁海县| 河曲县| 辽宁省| 潼关县| 太和县| 柳林县| 库车县| 台江县| 木里| 唐山市| 天津市| 吴川市| 会理县| 湛江市| 安化县| 华宁县| 仁怀市| 黎川县| 榆树市| 广宗县| 尚义县| 元朗区| 西和县| 哈巴河县| 新丰县| 海淀区| 博湖县| 五寨县| 乌什县| 东莞市| 车险| 栖霞市| 陇南市| 突泉县| 随州市| 河间市|