Skip to content

Instantly share code, notes, and snippets.

@wongalvis14
Created February 14, 2020 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wongalvis14/e4c1af431c20cb18d5457a372a32c3ec to your computer and use it in GitHub Desktop.
Save wongalvis14/e4c1af431c20cb18d5457a372a32c3ec to your computer and use it in GitHub Desktop.
Cupy sparse mean first draft
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