raghakot / keras-vis

Neural network visualization toolkit for keras
https://raghakot.github.io/keras-vis
MIT License
2.97k stars 664 forks source link

Using keras-vis on full convolutionnal net without input shape #144

Closed RomainCendre closed 5 years ago

RomainCendre commented 5 years ago

Hi everyone, I found this amazing project that give us abilities to visualize class activation map and many other stuff, but I would like to get an explanations on some points.

I'm using your tool on a full convolutionnal network at this time, because I need to classify image with very differents sizes and I'm trying to keep dynamic input. At this time, I'm using InceptionV3 with global average at the end. If I want to get visualize_cam for a specific input, I have to make new model instance with input shape specified, else in 'visualize_cam_with_losses' from saliency.py i will get NoneType in output_dims = utils.get_img_shape(penultimate_output)[2:]. Seems normal, because penultimate layer cannot deduce it size from unspecified input_shape.

But as we use visualize_cam on specific input data, we can deduce the size for the penultimate layer. So in my project, I just replace missings informations with new instruction that deduce shape from input data like this: output_dims = np.squeeze(penultimate_output_value,axis=0).shape[0:2] input_dims = np.squeeze(seed_input,axis=0).shape[0:2] And it seems works for my project.

I was wondering why we need to get the different needed size from layers, instead of data and from the results of the penultimate layer, but I think I'm missing something as this library need to be working with all needs.

I'm not trying to denigrate, I would like to understand if I'm doing something wrong. And I apologize for my english! =) Best regards, Romain

keisen commented 5 years ago

Hi @RomainCendre , Thank you for your report. Your question was to the point. Surely, visualize_com has the problem that it's not supported that full convolutional netowork without input shape. And It seems the problem is able to be avoided by improving as you said.

RomainCendre commented 5 years ago

Many thanks for your answer keisen! Hope it can help!

Any case, thanks to all of you for this amazing tool ;')