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

5.4.2 Visualizing Convnets Filters - Be careful about the code samples in the e-book

Open wzhings opened this issue 7 years ago • 6 comments

About the sample codes in Section 5.4.2 - Visualizing the Convnets Filters (PP 170), if you write the exact codes as written in the e-book. Probably you cannot display those filter images correctly as displayed in the book. If the results are blank, please change the final line: "plt.imshow(results)" into "plt.imshow(results.astype('uint8'))"

When I wrote these codes in Spyder, the interpretor reported some hints: "Clipping input data to the valid range for imshow with RGB data([0..1] for floats or [0..255] for integers". However, the type of "results" is float64. Therefore, please change the data type when you want to visualize these filters.

I was stuck by this errors for one night and felt frustrated. Hope you guys won't! Thank you.

wzhings avatar Nov 30 '18 01:11 wzhings

Thx, worked for me, could be a PR, if anybody cared...

plt.imshow(results.astype('uint8'))

ekkards avatar Jan 05 '19 22:01 ekkards

@wzhings @ekkards I am having some problems with this code. When visualizing filters of the VGG16 (which is selected by default in the book), it works fine. The code provides outputs as expected. But when trying the same code on any other model, like 'cats_and_dogs_small_2' used in 'Visualizing intermediate activations', the outputs for all the layers and their filters seems same and meaningless.

I don't see any kind of pattern in those images. They are all alike and meaningless. Can you please help?

ParikhKadam avatar Feb 10 '19 12:02 ParikhKadam

@fchollet Can you help please?

ParikhKadam avatar Feb 10 '19 12:02 ParikhKadam

@ParikhKadam the author does not respond here. You need to help yourself.

morenoh149 avatar Feb 10 '19 17:02 morenoh149

@morenoh149 Ohk...

ParikhKadam avatar Feb 12 '19 06:02 ParikhKadam

Thank you - saved me a lot of time. Worked!

dagrimm avatar Apr 16 '19 08:04 dagrimm