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

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>
主站蜘蛛池模板: 城市| 深泽县| 彰化县| 海淀区| 疏勒县| 新宁县| 驻马店市| 乾安县| 巴青县| 景德镇市| 洪江市| 乐平市| 韶关市| 濮阳县| 神农架林区| 古浪县| 嘉义县| 龙江县| 中阳县| 休宁县| 高阳县| 卓资县| 永寿县| 隆林| 辽宁省| 淮滨县| 民县| 沽源县| 大港区| 临汾市| 会东县| 桐柏县| 荥经县| 荔浦县| 太仓市| 南木林县| 那曲县| 麻城市| 台南县| 翼城县| 白山市|