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

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>
主站蜘蛛池模板: 铜梁县| 鄂托克旗| 东乌珠穆沁旗| 洛宁县| 合江县| 芷江| 绿春县| 青海省| 乡宁县| 枝江市| 通化市| 阜新市| 曲阳县| 余庆县| 九龙坡区| 密山市| 潼关县| 孝感市| 满洲里市| 泰和县| 蒙山县| 略阳县| 鄯善县| 赤城县| 定襄县| 鄂尔多斯市| 泾川县| 青海省| 莒南县| 南平市| 驻马店市| 浠水县| 庄河市| 大石桥市| 阳谷县| 顺义区| 金溪县| 阿鲁科尔沁旗| 应用必备| 茂名市| 黔东|