Hey, I was performing a class homework activity assigned to me and it was to use exclusively NumPy functions to achieve this functionality:
A = A1*A2*A3 + A4*A5*A6 + A7*A8*A9
Can anyone tell me how to do this?
Hey, I was performing a class homework activity assigned to me and it was to use exclusively NumPy functions to achieve this functionality:
A = A1*A2*A3 + A4*A5*A6 + A7*A8*A9
Can anyone tell me how to do this?
I am attaching below a code that might help you with this:
M
and V
of different shapes are created using the np.ones()
function.dot()
function performs matrix multiplication between these two arrays. Since V
has shape (p, n, 1)
, the result of the dot product will be a 3D array of shape (p, n, 1)
.squeeze()
function is used to remove the extra dimension of size 1
from the result of the dot product and the sum()
function is used to compute the sum of all elements in S
along the first dimension.(n, p)
, with all elements set to the value p * n
.