Closed afcruzs closed 7 years ago
Anyone has an answer on this?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.
I'm running into this as well. I'm trying to run an "improved" WGAN from here: https://github.com/eriklindernoren/Keras-GAN/tree/master/wgan_gp I only have access to the Theano backend on my cluster.
I need to compute the gradient of the output w.r.t to its weights, the keras backend has a method called gradients which seems to do the work. Here is a question on this matter:
http://stackoverflow.com/questions/39561560/getting-gradient-of-model-output-w-r-t-weights-using-keras
This seems to work pretty well on tensorflow, but when I run the code (with theano as a backend) of the accepted answer (which makes sense to me) it shows the following exception "TypeError: cost must be a scalar." when calling the tensor.grad method.
To actually run the gradients they use tensorflow, I wonder if there is a way of computing the gradients with keras without use an specific backend.
This is the code which fails when using theano as backend: