View source on GitHub |
Asserts that the given Tensor
is of the specified type.
tf.debugging.assert_type(
tensor, tf_type, message=None, name=None
)
This can always be checked statically, so this method returns nothing.
Example:
a = tf.Variable(1.0)
tf.debugging.assert_type(a, tf_type= tf.float32)
b = tf.constant(21)
tf.debugging.assert_type(b, tf_type=tf.bool)
Traceback (most recent call last):
TypeError: ...
c = tf.SparseTensor(indices=[[0, 0], [1, 2]], values=[1, 2],
dense_shape=[3, 4])
tf.debugging.assert_type(c, tf_type= tf.int32)
Raises | |
---|---|
TypeError
|
If the tensor's data type doesn't match tf_type .
|