python - 如何理解一维数组和二维数组的 numpy dot 生成的维度变化?
问题描述
我有两个数组,a 和 b。
In [168]: a.shape
Out[168]: (20, 3)
In [169]: b.shape
Out[169]: (20,)
这两者的点积是
In [171]: numpy.dot(b, a).shape
Out[171]: (3,)
我不明白为什么要得到(3,)
。a 和 b到底有什么numpy.dot
作用?
据我了解,背后的机制可能是这样的:
numpy.dot(a.T, b)
这是有道理的,因为(3, 20) * (20,) -> (3,)
. 但为什么numpy.dot(b, a)
,,(20,) * (20, 3)
也得到(3,)
?
解决方案
推荐阅读
- python - 尝试使用简单的 bs4 从 subreddit 的帖子中提取天赋。我的代码有什么问题?
- flutter - 无法在颤动中滚动到特定的小部件
- javascript - SSRS 报告中的 Mailto 链接
- sssd - MS Active Directory 和 Linux:使用 sssd 进行身份验证
- vaadin - Vaadin 焦点颜色
- android - Android Firebase 商店儿童计数到变量不起作用
- firebase - Swift Firebase 用户仅在重新启动应用程序后可用
- android - 任务':app:kaptGenerateStubsDebugKotlin'的错误执行失败。在 Android Studio 中运行项目时
- azure-devops - Azure DevOps - 如何使用组织策略创建新项目
- xcode - 如何在XCode 12.5中将标签宽度设置为不同视图中另一个标签的宽度