View source on GitHub |
Returns a tff.Type
for an obj
containing TensorFlow type specs.
tff.types.tensorflow_to_type(
obj: object
) -> tff.types.Type
This function extends tff.types.to_type
to handle TensorFlow type specs and
Python structures containing TensorFlow type specs:
tf.dtypes.DType
- tensor-like objects (e.g.
(tf.int32, tf.TensorShape([2, 3]))
) tf.TensorSpec
tf.data.DatasetSpec
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)))
Args | |
---|---|
obj
|
A tff.Type or an argument convertible to a tff.Type .
|