(self, data, rows, cols, shape=None, type_as=None)
| 3160 | return int(np.max(tensor)) + 1 |
| 3161 | |
| 3162 | def coo_matrix(self, data, rows, cols, shape=None, type_as=None): |
| 3163 | if shape is None: |
| 3164 | shape = ( |
| 3165 | self._convert_to_index_for_coo(rows), |
| 3166 | self._convert_to_index_for_coo(cols), |
| 3167 | ) |
| 3168 | if type_as is not None: |
| 3169 | data = self.from_numpy(data, type_as=type_as) |
| 3170 | |
| 3171 | sparse_tensor = tf.sparse.SparseTensor( |
| 3172 | indices=tnp.stack([rows, cols]).T, values=data, dense_shape=shape |
| 3173 | ) |
| 3174 | # if type_as is not None: |
| 3175 | # sparse_tensor = self.from_numpy(sparse_tensor, type_as=type_as) |
| 3176 | # SparseTensor are not subscriptable so we use dense tensors |
| 3177 | return self.todense(sparse_tensor) |
| 3178 | |
| 3179 | def issparse(self, a): |
| 3180 | return isinstance(a, tf.sparse.SparseTensor) |
nothing calls this directly
no test coverage detected