I have CNN models trained using Keras with Tensorflow backend. And I want to visualize my CNN filters with this tutorial: https://blog.keras.io/how-convolutional-neural-networks
Below, it's my example. Hope to help someone.
gradient = keras.backend.gradients(model.output, model.input)[2]
iterate = keras.backend.function(model.input, [gradient])
grad = iterate([patches, depthes, poses])
[patches, depthes, poses] is my model.input