更新时间:2022-06-04 03:10:43
您可以转置该数组以交换轴您想要在外面,相乘,然后转置回去:
You can automatically broadcast the vector against the outermost axis of an array. So, you can transpose the array to swap the axis you want to the outside, multiply, then transpose it back:
ares = (a.transpose(0,1,3,2) * v).transpose(0,1,3,2)