Logo

dev-resources.site

for different kinds of informations.

Answer: In numpy.sum() there is parameter called "keepdims". What does it do?

Published at
5/13/2023
Categories
Author
Jaweher Ben Salah
Categories
1 categories in total
open
Answer: In numpy.sum() there is parameter called "keepdims". What does it do?

An example showing keepdims in action when working with higher dimensional arrays. Let's see how the shape of the array changes as we do different reductions:

import numpy as np
a = np.random.rand(2,3,4)
a.shape
# => (2, 3, 4)
# Note: axis=0 refers to the first dimension of size 2
ā€¦

Featured ones: