raghakot / keras-vis

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

unable to reproduce results using seed_input method in visualize_activations #59

Closed Abhijit-2592 closed 7 years ago

Abhijit-2592 commented 7 years ago

This might not be an issue. It might be my wrong understanding also because, I am new to AI and Deep-learning I tried reproducing the results of the method visualize_activation by initializing the seed_input argument to seed_img. where seed_img is:

import numpy as np np.random.seed(5) seed_img = np.random.random((1, img_width, img_height, 3)) seed_img = (seed_img - 0.5) * 20 + 128

where img_width and img_height are 224,224 (VGG16)

when I run the visualize activation I am unable to reproduce the results. Can you please look into this? and correct me if the mistake is on my part. Thanks

raghakot commented 7 years ago

Can you post the full code gist? It should work, I need to debug it to see whats happening.

PS: For activation maximization, you can leave the seed_img as None and it will initialize it to the random value based on input_range.

Abhijit-2592 commented 7 years ago

I am using tensorflow background. The code is exactly the tutorial you provided for activation_maximization. with just the seed_img (specified above) passed to the seed_input argument. When I run the code for the first time I am getting a visualization image of ouzel. But if I re-run the code I am getting a different image each time.

PS: Thanks for your advice. But I specifically want to reproduce the results in my case (Mostly for documentation and stuffs for my project) And thanks for this awesome tool coz you have made visualizations of NNs especially CNNs damn easy. :)

Abhijit-2592 commented 7 years ago

My guess is, it is the inherent problem of keras using tensorflow background. This issue isn't sorted out yet in the keras thread.

raghakot commented 7 years ago

The results wont be exact because of randomness with backprop. It would give different results each time. You can control for this variance by setting tf and numpy random seed. Even then there are no gaurantees since some cuda ops are random.

Abhijit-2592 commented 7 years ago

@raghakot thanks