tff.types.tensorflow_to_type

Returns a tff.Type for an obj containing TensorFlow type specs.

Used in the notebooks

Used in the tutorials

This function extends tff.types.to_type to handle TensorFlow type specs and Python structures containing TensorFlow type specs:

For example:

tensorflow_to_type(tf.int32)
tff.TensorType(np.int32)
tensorflow_to_type((tf.int32, tf.TensorShape([2, 3])))
tff.TensorType(np.int32, (2, 3))
spec = tf.TensorSpec(shape=[2, 3], dtype=tf.int32)
tensorflow_to_type(spec)
tff.TensorType(np.int32, (2, 3))
spec = tf.data.DatasetSpec(tf.TensorSpec([2, 3], dtype=tf.int32))
tensorflow_to_type(spec)
tff.SequenceType(tff.TensorType(np.int32, (2, 3)))

obj A tff.Type or an argument convertible to a tff.Type.