theano: gradient where cost is imag(x)

泪湿孤枕 提交于 2019-12-24 03:59:49

问题


If I have a cost that is the imaginary part of a complex number, trying to obtain the gradient with theano I get the following error:

TypeError: Elemwise{imag,no_inplace}.grad illegally returned an integer-valued variable. (Input index 0, dtype complex128)

Is it not possible to use the imaginary part as cost despite it being a real-valued cost?


Edit. Minimal working example

import theano.tensor as T
from theano import function
a = T.zscalar('a')
f = function([a], T.grad(T.imag(a),a))

I would expect this to work as T.imag(a) is a real scalar cost..

来源:https://stackoverflow.com/questions/31731711/theano-gradient-where-cost-is-imagx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!