K.gradients(loss, input_img)[0] return “None”. (Keras CNN visualization with tensorflow backend)

后端 未结 3 471
猫巷女王i
猫巷女王i 2021-02-03 11:28

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

3条回答
  •  深忆病人
    2021-02-03 11:56

    I too had faced the same error @Jexus. For me the problem was:

    loss variable was None object. I had used

    loss.assign_add(....)
    

    instead of

    loss = loss + .....
    

    After changing that as mentioned, the loss was returning a tensor and hence

    grads = K.gradients(loss, model.input)[0]
    

    wasn't returning None.

提交回复
热议问题