-
-
Save wongalvis14/e4c1af431c20cb18d5457a372a32c3ec to your computer and use it in GitHub Desktop.
Cupy sparse mean first draft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mean(a, axis=None): | |
nRow = a.shape[0] | |
nCol = a.shape[1] | |
if not axis: | |
return cp.true_divide(a.sum(axis), nRow * nCol) | |
if axis == 0 or axis == -2: | |
return cp.true_divide(a.sum(axis), nRow) | |
else: | |
return cp.true_divide(a.sum(axis), nCol).flatten() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment