Christian - 3 months ago 18

Python Question

I have the following function:

`def logistic(y):`

print((1-y).shape)

print((y).shape)

return y*(1-y)

The dimensions of

`y`

`20 X 10`

`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

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