提交 f1152cf3 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Fixed typo in opt documentation

Also completed this doc and included a minor PEP8 fix
上级 c741196e
...@@ -235,7 +235,8 @@ def local_exp_over_1_plus_exp(node): ...@@ -235,7 +235,8 @@ def local_exp_over_1_plus_exp(node):
@gof.local_optimizer([tensor.mul]) @gof.local_optimizer([tensor.mul])
def local_sigm_times_exp(node): def local_sigm_times_exp(node):
""" """
exp(x)*sigm(-x) -> -sigm(x) exp(x) * sigm(-x) -> sigm(x)
exp(-x) * sigm(x) -> sigm(-x)
""" """
# this is a numerical stability thing, so we dont check clients # this is a numerical stability thing, so we dont check clients
if node.op == tensor.mul: if node.op == tensor.mul:
...@@ -283,9 +284,10 @@ def local_sigm_times_exp(node): ...@@ -283,9 +284,10 @@ def local_sigm_times_exp(node):
else: else:
other.append(i) other.append(i)
if did_something: if did_something:
terms = other + [sigmoid(x) for x in sigm_x] \ terms = (other +
+ [sigmoid(-x) for x in sigm_minus_x] [sigmoid(x) for x in sigm_x] +
if len(terms)>1: [sigmoid(-x) for x in sigm_minus_x])
if len(terms) > 1:
rval = tensor.mul(*terms) rval = tensor.mul(*terms)
else: else:
rval = terms[0] rval = terms[0]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论