提交 0e070ee0 authored 作者: Olivier Breuleux's avatar Olivier Breuleux

bugfix to Clip.grad

上级 df31e32f
...@@ -603,7 +603,7 @@ class Clip(ScalarOp): ...@@ -603,7 +603,7 @@ class Clip(ScalarOp):
def c_code(self, node, name, (x, min, max), (z, ), sub): def c_code(self, node, name, (x, min, max), (z, ), sub):
return "%(z)s = %(x)s < %(min)s ? %(min)s : %(x)s > %(max)s ? %(max)s : %(x)s;" % locals() return "%(z)s = %(x)s < %(min)s ? %(min)s : %(x)s > %(max)s ? %(max)s : %(x)s;" % locals()
def grad(self, (x, min, max), (gz, )): def grad(self, (x, min, max), (gz, )):
gx = (x > min and x < max) * gz gx = ((x > min) & (x < max)) * gz
return gx, None, None return gx, None, None
clip = Clip(transfer_type(0), name = 'clip') clip = Clip(transfer_type(0), name = 'clip')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论