tf.debugging.assert_type

Asserts that the given Tensor is of the specified type.

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)

tensor A Tensor, SparseTensor or tf.Variable . </td> </tr><tr> <td>tf_type<a id="tf_type"></a> </td> <td> A tensorflow type (<a href="../../tf/dtypes#float32"><code>dtypes.float32</code></a>, <a href="../../tf#int64"><code>tf.int64</code></a>, <a href="../../tf/dtypes#bool"><code>dtypes.bool</code></a>, etc). </td> </tr><tr> <td>message<a id="message"></a> </td> <td> A string to prefix to the default message. </td> </tr><tr> <td>name` A name for this operation. Defaults to "assert_type"

TypeError If the tensor's data type doesn't match tf_type.