Difference between numpy.dot and a.dot(b)

后端 未结 1 1727
傲寒
傲寒 2021-02-13 12:43

Is there a difference between

import numpy as np
np.dot(a,b)

and

a.dot(b)

internally? I wasn\'t able to find

1条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-13 13:06

    If a is an array, they're equivalent. The docs you couldn't find for the dot method are here, and they boil down to "see numpy.dot".

    If type(a) is not numpy.ndarray, then numpy.dot will convert a to an array and use the array for the multiplication, while a.dot will do whatever a's type says it does, or raise an AttributeError if a doesn't have a dot method.

    0 讨论(0)
提交回复
热议问题