MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / is_sparse

Function is_sparse

tensorflow/python/keras/backend.py:685–705  ·  view source on GitHub ↗

Returns whether a tensor is a sparse tensor. Arguments: tensor: A tensor instance. Returns: A boolean. Example: ```python >>> from keras import backend as K >>> a = K.placeholder((2, 2), sparse=False) >>> print(K.is_sparse(a)) False >>> b = K.placeholder((2, 2), spar

(tensor)

Source from the content-addressed store, hash-verified

683
684@keras_export('keras.backend.is_sparse')
685def is_sparse(tensor):
686 """Returns whether a tensor is a sparse tensor.
687
688 Arguments:
689 tensor: A tensor instance.
690
691 Returns:
692 A boolean.
693
694 Example:
695 ```python
696 >>> from keras import backend as K
697 >>> a = K.placeholder((2, 2), sparse=False)
698 >>> print(K.is_sparse(a))
699 False
700 >>> b = K.placeholder((2, 2), sparse=True)
701 >>> print(K.is_sparse(b))
702 True
703 ```
704 """
705 return isinstance(tensor, sparse_tensor.SparseTensor)
706
707
708@keras_export('keras.backend.to_dense')

Callers 3

to_denseFunction · 0.70
dotFunction · 0.70
concatenateFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected