提交 c712b8a3 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Zero gradient when the output is an int.

上级 96f4e9f3
......@@ -1655,8 +1655,14 @@ class Mod(BinaryScalarOp):
""") % locals()
def grad(self, (x, y), (gz, )):
z = self(x, y)
if z.type.dtype in discrete_types:
# The gradient does not flow in if the output is discrete
return [x.zeros_like(dtype=theano.config.floatX),
y.zeros_like(dtype=theano.config.floatX)]
return [gz,
-(x//y) * gz ]
-(x // y) * gz]
mod = Mod(upcast_out, name='mod')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论