Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Numpy
y= a.mean(axis=1)
print(y)
#[Output]:
#[0.5 2.5 4.5]
y.reshape(3,1)
#[Output]:
#array([[0.5],
# [2.5],
# [4.5]])
print(a-y.reshape(3,1))
#[Output]:
#[[-0.5 0.5]
# [-0.5 0.5]
# [-0.5 0.5]]
z = np.sum(np.square(a-y.reshape(3,1)),axis=1)
print(z)
#[Output]:
#[0.5 0.5 0.5]
print(z/a.shape[1])
#[Output]:
#array([0.25, 0.25, 0.25])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.