Open KevinLikesDringCoffe opened 2 years ago
I'm running sparse tucker examples in [07_pydata_sparse_backend]. However when executing tensor.max() , TypeError is reported.
tensor.max()
TypeError Traceback (most recent call last) Input In [9], in <cell line: 2>() 1 # The most frequently a word has been used in a single paper ----> 2 tensor.max() File ~/bench/sparse/sparse/_sparse_array.py:444, in SparseArray.max(self, axis, keepdims, out) 421 def max(self, axis=None, keepdims=False, out=None): 422 """ 423 Maximize along the given axes. Uses all axes by default. 424 (...) 442 scipy.sparse.coo_matrix.max : Equivalent Scipy function. 443 """ --> 444 return np.maximum.reduce(self, out=out, axis=axis, keepdims=keepdims) File ~/bench/sparse/sparse/_sparse_array.py:307, in SparseArray.__array_ufunc__(self, ufunc, method, *inputs, **kwargs) 305 result = elemwise(ufunc, *inputs, **kwargs) 306 elif method == "reduce": --> 307 result = SparseArray._reduce(ufunc, *inputs, **kwargs) 308 else: 309 return NotImplemented File ~/bench/sparse/sparse/_sparse_array.py:278, in SparseArray._reduce(method, *args, **kwargs) 275 if isinstance(self, ss.spmatrix): 276 self = type(self).from_scipy_sparse(self) --> 278 return self.reduce(method, **kwargs) File ~/bench/sparse/sparse/_sparse_array.py:360, in SparseArray.reduce(self, method, axis, keepdims, **kwargs) 358 if not isinstance(axis, tuple): 359 axis = (axis,) --> 360 out = self._reduce_calc(method, axis, keepdims, **kwargs) 361 if len(out) == 1: 362 return out[0] File ~/bench/sparse/sparse/_coo/core.py:698, in COO._reduce_calc(self, method, axis, keepdims, **kwargs) 691 a = self.transpose(neg_axis + axis) 692 a = a.reshape( 693 ( 694 np.prod([self.shape[d] for d in neg_axis], dtype=np.intp), 695 np.prod([self.shape[d] for d in axis], dtype=np.intp), 696 ) 697 ) --> 698 data, inv_idx, counts = _grouped_reduce(a.data, a.coords[0], method, **kwargs) 699 n_cols = a.shape[1] 700 arr_attrs = (a, neg_axis, inv_idx) File ~/bench/sparse/sparse/_coo/core.py:1574, in _grouped_reduce(x, groups, method, **kwargs) 1571 # Partial credit to @shoyer 1572 # Ref: https://gist.github.com/shoyer/f538ac78ae904c936844 1573 inv_idx, counts = _calc_counts_invidx(groups) -> 1574 result = method.reduceat(x, inv_idx, **kwargs) 1575 return result, inv_idx, counts TypeError: Cannot cast array data from dtype('uint64') to dtype('int64') according to the rule 'safe'
How can I solve this problem?
I'm running sparse tucker examples in [07_pydata_sparse_backend]. However when executing
tensor.max()
, TypeError is reported.How can I solve this problem?