deep-learning-with-python-notebooks icon indicating copy to clipboard operation
deep-learning-with-python-notebooks copied to clipboard

5.4 Visualizing what convnets learn,why convolution is green when visualizing images

Open cdata123 opened this issue 4 years ago • 3 comments

Why convolution is green when visualizing images? BXJ6U1AIIU5J}MNLI`PA@$P

cdata123 avatar Jun 20 '20 07:06 cdata123

 plt.imshow(display_grid, aspect='auto', cmap='viridis')

Hi, please take a look at the last sentence. display_grid is a numpy 2D array which is not RGB data. So the programmer have to use cmap to appoint the style. And virdis represents blue-green-yellow. Here is part of the matplotlib documentation.

cmp:cmapstr or Colormap, optional
The Colormap instance or registered colormap name used to map scalar data to colors.  
This parameter is ignored for RGB(A) data. Defaults to rcParams["image.cmap"] (default: 'viridis').

So actually the color has nothing to with the color of the input image, because it has been processed to a 4D tensor before inputting to the convnet.

谢谢~

XZLeo avatar Jun 20 '20 15:06 XZLeo

Your answer is very helpful to me, thanks

cdata123 avatar Jun 22 '20 00:06 cdata123

A big compliment to you.@ @XZLeo

TangXu-cell avatar Apr 21 '21 10:04 TangXu-cell