March 2019
Intermediate to advanced
196 pages
4h 50m
English
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) # 42i
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) # 4j
The output will be as follows:
<tf.Tensor: id=119, shape=(), dtype=int32, numpy=4>
Read now
Unlock full access