In other words, I’m wondering why keepdims is False by default on functions like np.max() or np.sum() when you supply an axis. Seems to me like retaining dimensions would be preferable in pretty much every case but I don’t have enough experience to know if that’s actually true. In fact I can’t even figure out why keepdims would need to be an argument to begin with. If I wanted to sum some data like:
inputs =
[[1 2 3]
[1 2 3]
[1 2 3]]
And let’s say I ran
np.sum(inputs, axis=1)
Why would I ever want the output to be this:
[3 6 9]
Rather than this?
[[3]
[6]
[9]]
Even if you want it that way you can just transpose it afterward, right? I feel like there must be a good reason Numpy does this but I can’t figure out why.
submitted by /u/Schnauzerofdoom
[link] [comments]
r/learnpython In other words, I’m wondering why keepdims is False by default on functions like np.max() or np.sum() when you supply an axis. Seems to me like retaining dimensions would be preferable in pretty much every case but I don’t have enough experience to know if that’s actually true. In fact I can’t even figure out why keepdims would need to be an argument to begin with. If I wanted to sum some data like: inputs = [[1 2 3] [1 2 3] [1 2 3]] And let’s say I ran np.sum(inputs, axis=1) Why would I ever want the output to be this: [3 6 9] Rather than this? [[3] [6] [9]] Even if you want it that way you can just transpose it afterward, right? I feel like there must be a good reason Numpy does this but I can’t figure out why. submitted by /u/Schnauzerofdoom [link] [comments]
In other words, I’m wondering why keepdims is False by default on functions like np.max() or np.sum() when you supply an axis. Seems to me like retaining dimensions would be preferable in pretty much every case but I don’t have enough experience to know if that’s actually true. In fact I can’t even figure out why keepdims would need to be an argument to begin with. If I wanted to sum some data like:
inputs =
[[1 2 3]
[1 2 3]
[1 2 3]]
And let’s say I ran
np.sum(inputs, axis=1)
Why would I ever want the output to be this:
[3 6 9]
Rather than this?
[[3]
[6]
[9]]
Even if you want it that way you can just transpose it afterward, right? I feel like there must be a good reason Numpy does this but I can’t figure out why.
submitted by /u/Schnauzerofdoom
[link] [comments]