Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个a形状为 (32,3,5,5) 的多维数组和v一个形状为 (32,) 的数组。我如何使用除 for 循环以外的 numpy 将 (i,3,5,5) 与 (i,) 相乘?
a
v
使用a和v作为两个数组,可以建议的方法很少 -
a*v[:,None,None,None] a*v.reshape(-1, *[1]*3) (a.T * v).T np.einsum('i...,i->i...', a, v)