提交 2708c77e authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Update threshold for float16.

上级 4b16616f
...@@ -68,8 +68,9 @@ class ScalarSigmoid(scalar.UnaryScalarOp): ...@@ -68,8 +68,9 @@ class ScalarSigmoid(scalar.UnaryScalarOp):
# (theano._asarray(1.0, dtype=dt) + # (theano._asarray(1.0, dtype=dt) +
# numpy.exp(-theano._asarray([i,-i], dtype=dt)))) # numpy.exp(-theano._asarray([i,-i], dtype=dt))))
if (node.inputs[0].type == scalar.float32 or if node.inputs[0].type == scalar.float16:
node.inputs[0].type == scalar.float16): return """%(z)s = %(x)s < -11.0f ? 0.0 : %(x)s > 7.0f ? 1.0f : 1.0f /(1.0f + exp(-%(x)s));""" % locals()
elif node.inputs[0].type == scalar.float32:
return """%(z)s = %(x)s < -88.0f ? 0.0 : %(x)s > 15.0f ? 1.0f : 1.0f /(1.0f + exp(-%(x)s));""" % locals() return """%(z)s = %(x)s < -88.0f ? 0.0 : %(x)s > 15.0f ? 1.0f : 1.0f /(1.0f + exp(-%(x)s));""" % locals()
elif node.inputs[0].type == scalar.float64: elif node.inputs[0].type == scalar.float64:
return """%(z)s = %(x)s < -709.0 ? 0.0 : %(x)s > 19.0 ? 1.0 : 1.0 /(1.0+exp(-%(x)s));""" % locals() return """%(z)s = %(x)s < -709.0 ? 0.0 : %(x)s > 19.0 ? 1.0 : 1.0 /(1.0+exp(-%(x)s));""" % locals()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论