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

Function to_dense

tensorflow/python/keras/backend.py:709–732  ·  view source on GitHub ↗

Converts a sparse tensor into a dense tensor and returns it. Arguments: tensor: A tensor instance (potentially sparse). Returns: A dense tensor. Examples: ```python >>> from keras import backend as K >>> b = K.placeholder((2, 2), sparse=True) >>> print(K.is_sparse(b))

(tensor)

Source from the content-addressed store, hash-verified

707
708@keras_export('keras.backend.to_dense')
709def to_dense(tensor):
710 """Converts a sparse tensor into a dense tensor and returns it.
711
712 Arguments:
713 tensor: A tensor instance (potentially sparse).
714
715 Returns:
716 A dense tensor.
717
718 Examples:
719 ```python
720 >>> from keras import backend as K
721 >>> b = K.placeholder((2, 2), sparse=True)
722 >>> print(K.is_sparse(b))
723 True
724 >>> c = K.to_dense(b)
725 >>> print(K.is_sparse(c))
726 False
727 ```
728 """
729 if is_sparse(tensor):
730 return sparse_ops.sparse_tensor_to_dense(tensor)
731 else:
732 return tensor
733
734
735@keras_export('keras.backend.name_scope', v1=[])

Callers 2

evalFunction · 0.85
concatenateFunction · 0.85

Calls 1

is_sparseFunction · 0.70

Tested by

no test coverage detected