Created
June 17, 2016 20:09
-
-
Save doubledare704/23e5f865bbb4bc2e9f78d8897f3cd3ec to your computer and use it in GitHub Desktop.
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
import numpy as np | |
n = 10 | |
a = np.random.randint(0, 10, (n, n, n)) | |
print("All matrix: {0}".format(a)) | |
columns = a.sum(axis=0) | |
rows = a.sum(axis=1) | |
z_s = a.sum(axis=2) | |
t = columns.max() | |
print("Max value in columns {0}".format(t)) | |
i, j = np.unravel_index(columns.argmax(), columns.shape) | |
print("Element in[{0}, {1}, {2}]".format(i, j, 0)) | |
t = rows.max() | |
print("Max value in rows {0}".format(t)) | |
i, j = np.unravel_index(rows.argmax(), rows.shape) | |
print("Element in[{0}, {1}, {2}]".format(j, i, 0)) | |
t = z_s.max() | |
print("Max value in z-dim {0}".format(t)) | |
i, j = np.unravel_index(z_s.argmax(), z_s.shape) | |
print("Element in[{0}, {1}, {2}]".format(0, j, i)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment