提交 3031b1c7 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

Maximum.grad

上级 cd6f4ae4
...@@ -1098,11 +1098,15 @@ class Maximum(BinaryScalarOp): ...@@ -1098,11 +1098,15 @@ class Maximum(BinaryScalarOp):
def grad(self, (x, y), (gz, )): def grad(self, (x, y), (gz, )):
assert gz.type not in complex_types assert gz.type not in complex_types
# max is not defined for complex_types # max is not defined for complex_types
gx, gy = None, None
if x.type in float_types: output = self(x,y)
gx = cast(eq(maximum(x, y), x) * gz, x.type.dtype)
if y.type in float_types: if output.type in discrete_types:
gy = cast(eq(maximum(x, y), y) * gz, y.type.dtype) return [x.zeros_like().astype(theano.config.floatX),
y.zeros_like().astype(theano.config.floatX)]
gx = eq(output, x) * gz
gy = eq(output, y) * gz
return (gx, gy) return (gx, gy)
maximum = Maximum(upcast_out, name='maximum') maximum = Maximum(upcast_out, name='maximum')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论