Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
dcbc3e43
提交
dcbc3e43
authored
2月 19, 2010
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Commented on why local_1msigmoid is not registered. Modified 1msigmoid test to not run
when the 1msigmoid optimization is not registered.
上级
c42414b6
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
16 行增加
和
7 行删除
+16
-7
sigm.py
theano/tensor/nnet/sigm.py
+12
-3
test_sigm.py
theano/tensor/nnet/tests/test_sigm.py
+4
-4
没有找到文件。
theano/tensor/nnet/sigm.py
浏览文件 @
dcbc3e43
...
@@ -294,9 +294,8 @@ def local_inv_1_plus_exp(node):
...
@@ -294,9 +294,8 @@ def local_inv_1_plus_exp(node):
sigmoid
(
tensor
.
neg
(
nonconsts
[
0
]
.
owner
.
inputs
[
0
])),
sigmoid
(
tensor
.
neg
(
nonconsts
[
0
]
.
owner
.
inputs
[
0
])),
scalar_inputs
)
scalar_inputs
)
# Registration is below, and conditional.
#@opt.register_canonicalize
@gof.local_optimizer
([
tensor
.
sub
])
@gof.local_optimizer
([
tensor
.
inv
])
def
local_1msigmoid
(
node
):
def
local_1msigmoid
(
node
):
"""
"""
1-sigm(x) -> sigm(-x)
1-sigm(x) -> sigm(-x)
...
@@ -313,3 +312,13 @@ def local_1msigmoid(node):
...
@@ -313,3 +312,13 @@ def local_1msigmoid(node):
if
numpy
.
allclose
(
numpy
.
sum
(
val_l
),
1
):
if
numpy
.
allclose
(
numpy
.
sum
(
val_l
),
1
):
return
[
sigmoid
(
-
sub_r
.
owner
.
inputs
[
0
])]
return
[
sigmoid
(
-
sub_r
.
owner
.
inputs
[
0
])]
register_local_1msigmoid
=
False
# This is False because the Stabilize pattern above
# is looking for 1-sigm. Also Canonizer turns neg into *(-1) and so
# this optimization might set off an unwanted chain of things.
# OTH - this transformation can be seen as pushing normal arithmetic either below or above the
# sigmoidal nonlinearity... so if the canonicalized form had anything to say about that then it
# would be a consideration... anyway leaving False for now.
if
register_local_1msigmoid
:
opt
.
register_canonicalize
(
local_1msigmoid
)
theano/tensor/nnet/tests/test_sigm.py
浏览文件 @
dcbc3e43
...
@@ -7,6 +7,7 @@ from theano.tests import unittest_tools as utt
...
@@ -7,6 +7,7 @@ from theano.tests import unittest_tools as utt
from
theano.tensor.tests
import
test_basic
as
TT
from
theano.tensor.tests
import
test_basic
as
TT
from
theano.tensor.nnet
import
*
from
theano.tensor.nnet
import
*
from
theano.tensor.nnet.sigm
import
register_local_1msigmoid
class
T_sigmoid
(
unittest
.
TestCase
):
class
T_sigmoid
(
unittest
.
TestCase
):
...
@@ -21,7 +22,6 @@ class T_softplus(unittest.TestCase):
...
@@ -21,7 +22,6 @@ class T_softplus(unittest.TestCase):
def
test_elemwise
(
self
):
def
test_elemwise
(
self
):
utt
.
verify_grad
(
softplus
,
[
numpy
.
random
.
rand
(
3
,
4
)])
utt
.
verify_grad
(
softplus
,
[
numpy
.
random
.
rand
(
3
,
4
)])
class
T_sigmoid_opts
(
unittest
.
TestCase
):
class
T_sigmoid_opts
(
unittest
.
TestCase
):
def
test_exp_over_1_plus_exp
(
self
):
def
test_exp_over_1_plus_exp
(
self
):
m
=
theano
.
config
.
mode
m
=
theano
.
config
.
mode
...
@@ -53,6 +53,9 @@ class T_sigmoid_opts(unittest.TestCase):
...
@@ -53,6 +53,9 @@ class T_sigmoid_opts(unittest.TestCase):
T
.
mul
]
T
.
mul
]
def
test_1msigmoid
(
self
):
def
test_1msigmoid
(
self
):
if
not
register_local_1msigmoid
:
return
m
=
theano
.
config
.
mode
m
=
theano
.
config
.
mode
if
m
==
'FAST_COMPILE'
:
if
m
==
'FAST_COMPILE'
:
m
=
'FAST_RUN'
m
=
'FAST_RUN'
...
@@ -70,6 +73,3 @@ class T_sigmoid_opts(unittest.TestCase):
...
@@ -70,6 +73,3 @@ class T_sigmoid_opts(unittest.TestCase):
assert
[
node
.
op
for
node
in
f
.
maker
.
env
.
toposort
()]
==
[
tensor
.
neg
,
assert
[
node
.
op
for
node
in
f
.
maker
.
env
.
toposort
()]
==
[
tensor
.
neg
,
sigmoid_inplace
]
sigmoid_inplace
]
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论