tf.keras.backend.is_sparse

TensorFlow 1 version View source on GitHub

Returns whether a tensor is a sparse tensor.

tf.keras.backend.is_sparse(
    tensor
)

Arguments:

  • tensor: A tensor instance.

Returns:

A boolean.

Example:

a = tf.keras.backend.placeholder((2, 2), sparse=False) 
print(tf.keras.backend.is_sparse(a)) 
False 
b = tf.keras.backend.placeholder((2, 2), sparse=True) 
print(tf.keras.backend.is_sparse(b)) 
True