matplotlib.pyplot.imshow

官方:Display an image on the axes.

注意这个参数X

X : array_like, shape (n, m) or (n, m, 3) or (n, m, 4)

Display the image in X to current axes. X may be a float array, a uint8 array or a PIL image. If X is an array, it can have the following shapes:

MxN – luminance (grayscale, float array only)
MxNx3 – RGB (float or uint8 array)
MxNx4 – RGBA (float or uint8 array)
The value for each component of MxNx3 and MxNx4 float arrays should be in the range 0.0 to 1.0; MxN float arrays may be normalised.

输入参数X的shape为: (n, m) or (n, m, 3) or (n, m, 4). 若为(m,n,5)会报错。

在deep learning 可视化中,经常需要可视化N×C×H×W的数据,而imshow的输入只能为(n, m) or (n, m, 3) or (n, m, 4),所以必须将N×C×H×W的数据转换:
1. 如果C=3 or 4, 则需将N×H×W的数据转换成N×M形式的,具体见show_data,这样,可以得到彩图。
2. 如果C>4, 比如某一层卷积核参数总共为32×32×5×5,就要可视化32^2 ×5×5的数据,即可视化32^2个卷积核,得到的是灰度图,具体见show_features.在show_data或show_feature中,要经过reshape, transpose,再reshape的操作。
3. 总之需要记住:输入参数X的shape为: (n, m) or (n, m, 3) or (n, m, 4).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值