Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python .T.dot() numpy syntax understanding

Tags:

python

numpy

Might I ask more info about this syntax?

l1.T.dot(l2_delta)

I was under the impression np.dot(x,y) took two arrays as parameters

Does this line means transpose of l1 and then multiply l2_delta still?

Thanks


2 Answers

Your understanding of what your code is doing is correct.

Your confusion is coming from the fact that there are two kinds of numpy "dot" functions:

  • The numpy dot function, which takes two arguments:

    • https://docs.scipy.org/doc/numpy/reference/generated/numpy.dot.html
  • The dot function that belongs to numpy ndarray objects, which has only one argument:

    • https://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.ndarray.dot.html

Similarly, here's the ".T" function that belongs to ndarray objects: https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.T.html

like image 161
Brian Bartoldson Avatar answered May 31 '26 07:05

Brian Bartoldson


vec.dot(vec2) == np.dot(vec, vec2)

So yes, you're correct.

https://docs.scipy.org/doc/numpy/reference/generated/numpy.dot.html https://docs.scipy.org/doc/numpy/reference/generated/numpy.matrix.dot.html

like image 31
c2huc2hu Avatar answered May 31 '26 05:05

c2huc2hu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!