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)
| 707 | |
| 708 | @keras_export('keras.backend.to_dense') |
| 709 | def 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=[]) |
no test coverage detected