You can check their dtype attributes e.g. assert my_tensor.dtype == tf.float32
.
Tensors are immutable outside of variables: they describe relationships between quantities. Data types will not change unless a type cast operation is added to the graph, adding an edge. If a value is passed to a tensor with a type that is different to the expected type, e.g. when loading data into a pipeline, an error is raised. You can check this by assigning a tensor with an incorrect type -- you will get an error.
Try this code
import tensorflow as tf
x = tf.get_variable('x', shape=(2,), dtype=tf.float32)
tf.assign(x[1], tf.ones(shape=(2,), dtype=tf.int32))
You should get an error to the effect of "TypeError: Input 'value' of 'StridedSliceAssign' Op has type int32 that does not match type float32 of argument 'ref'."