Christian Christian - 9 months ago 33
Python Question

Anomaly in python with matrix multiplication

I have the following function:

def logistic(y):
return y*(1-y)

The dimensions of
20 X 10
. This function prints

20 X 10
20 X 10

And the function returns another matrix of dimension
20 X 10
In vector multiplication, the number of columns of the first argument must equal the number of rows of the 2nd argument. Even though this is not the case, how am I able to successfully execute this function?

Answer Source

"Because * does not do matrix multiplication. Rather, it does elementwise multiplication. Try or the @ operator if you have new enough python." Provided by User: jme