测试程序:
import numpy as np
A=np.random.randn(4,3)
B=np.random.randn(5,4,3)
print(A,A.shape)
print(B,B.shape)
测试结果:
[[ 1.65116631 0.65433859 0.60835888]
[-0.5105315 1.27626974 -1.17579392]
[-0.21566487 -0.57976917 1.59900943]
[ 1.00468399 -0.38331758 1.49912217]] (4, 3)
[[[-0.54863125 1.26576023 -2.95168856]
[ 0.27166768 -0.90973455 -1.70130229]
[ 1.4344519 0.46945974 -0.51778667]
[ 0.82859325 -2.55669375 -1.15995574]]
[[-1.867543 1.26659434 1.09745486]
[-0.68603883 0.83188864 0.01995746]
[ 0.10028617 0.55817263 -1.10271119]
[ 0.17845894 0.05393899 -0.74882348]]
[[-0.54340926 -0.36803138 1.70142752]
[-1.56940267 -0.45341488 0.25691709]
[ 1.00348669 -0.30357184 0.11269915]
[-0.75230232 -0.66815715 0.1445032 ]]
[[-1.4450306 0.32532832 -0.84110991]
[ 0.57615025 2.47953269 0.47464932]
[-0.45915104 1.09317274 -1.26994611]
[ 2.74141194 1.52149005 -0.08431544]]
[[-0.57330565 -0.77312988 -0.35378862]
[-0.74788065 1.34449482 -0.04547778]
[-0.86599271 -0.48533614 0.08144477]
[ 0.82996177 1.18632351 0.10067105]]] (5, 4, 3)
Process finished with exit code 0