Creating Tensors: Setting DataTypes

In [1]:
import tensorflow as tf
In [2]:
floatArr = [1.7, 7.4]
tensorFloat = tf.constant(floatArr)
tensorFloat.dtype
Out [2]:
tf.float32
In [4]:
# 
# using tf.cast
# 
castedAs16 = tf.cast(tensorFloat, dtype=tf.float16)
castedAs16.dtype
Out [4]:
tf.float16