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

偶尔善良 提交于 2020-02-26 14:08:02

问题


Is there a difference between

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

and

a.dot(b)

internally? I wasn't able to find any documentation on the latter method.


回答1:


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.



来源:https://stackoverflow.com/questions/42517281/difference-between-numpy-dot-and-a-dotb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!