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

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>
主站蜘蛛池模板: 铅山县| 南充市| 彩票| 海丰县| 德令哈市| 元谋县| 灵丘县| 滦南县| 双鸭山市| 南安市| 柳河县| 长子县| 宜良县| 安溪县| 随州市| 霍林郭勒市| 庆阳市| 盘锦市| 郴州市| 德令哈市| 枣强县| 长泰县| 菏泽市| 巴南区| 鄯善县| 衡水市| 屯留县| 北流市| 陆良县| 仙桃市| 星子县| 鸡西市| 拉孜县| 邵阳市| 沽源县| 寿阳县| 焉耆| 澎湖县| 和田市| 宿州市| 马尔康县|