【发布时间】:2017-01-26 10:59:24
【问题描述】:
我对使用 Keras API 的简单性构建强化学习模型很感兴趣。不幸的是,我无法提取输出相对于权重的梯度(不是错误)。我发现以下代码执行了类似的功能(Saliency maps of neural networks (using Keras))
get_output = theano.function([model.layers[0].input],model.layers[-1].output,allow_input_downcast=True)
fx = theano.function([model.layers[0].input] ,T.jacobian(model.layers[-1].output.flatten(),model.layers[0].input), allow_input_downcast=True)
grad = fx([trainingData])
任何关于如何计算模型输出相对于每一层权重的梯度的想法都将不胜感激。
【问题讨论】:
-
你有预付款吗?我使用类似的显着性函数收到以下错误:github.com/fchollet/keras/issues/1777#issuecomment-250040309
-
我在 Keras 上没有取得任何成功。但是,我已经能够使用 tensorflow 做到这一点。
-
github.com/yanpanlau/DDPG-Keras-TorcsCriticNetwork.py 使用 tensorflow 后端计算梯度,同时使用 Keras 实际构建网络架构