1.numpy Rising dimension a.expand_dims(a,axis=0)
Be careful unsqueeze(x,axis=0) yes torch In the middle of the day ,np No such attribute
2. The stack stack
np.stack((a,b),axis=0)
axis=0 Indicates stacking on a batch , If the picture dimension is (1,2,6,3), So after stacking, there will be (2,1,2,6,3)
3. So when there is a batch of pictures, you should use np.connect()
3.matpltlib The display is (H,W,C), And is RGB The order
for feature_map in out_put:
#[N,C,H,W]->[C,H,W]
im=np.squeeze(feature_map.detach().numpy())
#[C,H,W]->[H,W,C]
im=np.transpose(im,[1,2,0])
#show top 12 feature maps
plt.figure()
for i in range(12):
ax=plt.subplot(3,4,i+1)
#[H,W,C]
plt.imshow(im[:,:,i],cmap='gray')
plt.show()