Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
24f6a4e5
提交
24f6a4e5
authored
6月 17, 2015
作者:
Harm de Vries
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix in local_argmax_pushdown
上级
83ea3e8f
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
8 行增加
和
8 行删除
+8
-8
nnet.py
theano/tensor/nnet/nnet.py
+4
-4
test_nnet.py
theano/tensor/nnet/tests/test_nnet.py
+4
-4
没有找到文件。
theano/tensor/nnet/nnet.py
浏览文件 @
24f6a4e5
...
@@ -86,8 +86,8 @@ class SoftmaxWithBias(gof.Op):
...
@@ -86,8 +86,8 @@ class SoftmaxWithBias(gof.Op):
x_plus_b
=
x
+
b
[
None
,
:]
x_plus_b
=
x
+
b
[
None
,
:]
e_x
=
numpy
.
exp
(
x_plus_b
-
x_plus_b
.
max
(
axis
=
1
)[:,
None
])
e_x
=
numpy
.
exp
(
x_plus_b
-
x_plus_b
.
max
(
axis
=
1
)[:,
None
])
sm
=
e_x
/
e_x
.
sum
(
axis
=
1
)[:,
None
]
e_x
*=
1.0
/
e_x
.
sum
(
axis
=
1
)[:,
None
]
output_storage
[
0
][
0
]
=
sm
output_storage
[
0
][
0
]
=
e_x
def
grad
(
self
,
inp
,
grads
):
def
grad
(
self
,
inp
,
grads
):
x
,
b
=
inp
x
,
b
=
inp
...
@@ -1469,7 +1469,7 @@ def local_softmax_grad_to_crossentropy_with_softmax_grad(node):
...
@@ -1469,7 +1469,7 @@ def local_softmax_grad_to_crossentropy_with_softmax_grad(node):
def
local_argmax_pushdown
(
node
):
def
local_argmax_pushdown
(
node
):
if
node
.
op
==
tensor
.
_max_and_argmax
and
node
.
inputs
[
0
]
.
owner
and
\
if
node
.
op
==
tensor
.
_max_and_argmax
and
node
.
inputs
[
0
]
.
owner
and
\
len
(
node
.
outputs
[
0
]
.
clients
)
>
0
and
node
.
inputs
[
0
]
.
owner
.
op
in
\
len
(
node
.
outputs
[
0
]
.
clients
)
>
0
and
node
.
inputs
[
0
]
.
owner
.
op
in
\
(
softmax
,
softplus
,
tensor
.
exp
,
tensor
.
log
,
tensor
.
tanh
,
sigmoid
,
(
softmax
_op
,
softplus
,
tensor
.
exp
,
tensor
.
log
,
tensor
.
tanh
,
sigmoid
,
softmax_with_bias
):
softmax_with_bias
):
if
theano
.
config
.
warn
.
argmax_pushdown_bug
:
if
theano
.
config
.
warn
.
argmax_pushdown_bug
:
logging
.
getLogger
(
'theano.tensor.nnet.nnet'
)
.
warn
(
"WARNING: there "
logging
.
getLogger
(
'theano.tensor.nnet.nnet'
)
.
warn
(
"WARNING: there "
...
@@ -1485,7 +1485,7 @@ def local_argmax_pushdown(node):
...
@@ -1485,7 +1485,7 @@ def local_argmax_pushdown(node):
x_max
,
x_argmax
=
node
.
outputs
x_max
,
x_argmax
=
node
.
outputs
x
,
axis
=
node
.
inputs
x
,
axis
=
node
.
inputs
# TODO: Make a list/set of monotonic ops...
# TODO: Make a list/set of monotonic ops...
if
x
.
owner
and
x
.
owner
.
op
in
(
softmax
,
softplus
,
tensor
.
exp
,
if
x
.
owner
and
x
.
owner
.
op
in
(
softmax
_op
,
softplus
,
tensor
.
exp
,
tensor
.
log
,
tensor
.
tanh
,
sigmoid
):
tensor
.
log
,
tensor
.
tanh
,
sigmoid
):
pre_x
,
=
x
.
owner
.
inputs
pre_x
,
=
x
.
owner
.
inputs
return
tensor
.
_max_and_argmax
(
pre_x
,
axis
)
return
tensor
.
_max_and_argmax
(
pre_x
,
axis
)
...
...
theano/tensor/nnet/tests/test_nnet.py
浏览文件 @
24f6a4e5
...
@@ -1011,7 +1011,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
...
@@ -1011,7 +1011,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
try
:
try
:
g
=
theano
.
function
([
x
,
b
,
y
],
T
.
grad
(
expr
,
x
),
mode
=
mode
)
g
=
theano
.
function
([
x
,
b
,
y
],
T
.
grad
(
expr
,
x
),
mode
=
mode
)
finally
:
finally
:
config
.
warn
.
sum_div_dimshuffle_
q
bug
=
backup
config
.
warn
.
sum_div_dimshuffle_bug
=
backup
if
verbose
:
if
verbose
:
printing
.
debugprint
(
g
)
printing
.
debugprint
(
g
)
...
@@ -1026,7 +1026,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
...
@@ -1026,7 +1026,7 @@ class T_CrossentropyCategorical1Hot(utt.InferShapeTester):
theano
.
printing
.
debugprint
(
g
)
theano
.
printing
.
debugprint
(
g
)
raise
raise
def
test_
s
crossentropy_softmax_1hot_with_bias_dxcale_cost
(
self
):
def
test_crossentropy_softmax_1hot_with_bias_dxcale_cost
(
self
):
# TODO: add the optimization in FAST_COMPILE?
# TODO: add the optimization in FAST_COMPILE?
# In the mean time, run it as 'FAST_RUN' instead
# In the mean time, run it as 'FAST_RUN' instead
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
...
@@ -1130,7 +1130,7 @@ def test_argmax_pushdown():
...
@@ -1130,7 +1130,7 @@ def test_argmax_pushdown():
# test that the max_and_argmax is pushed down if the max is not used
# test that the max_and_argmax is pushed down if the max is not used
out
=
tensor
.
max_and_argmax
(
out
=
tensor
.
max_and_argmax
(
softmax
(
tensor
.
exp
(
tensor
.
tanh
(
sigmoid
(
x
)))),
softmax
_graph
(
tensor
.
exp
(
tensor
.
tanh
(
sigmoid
(
x
)))),
axis
=-
1
)[
1
]
axis
=-
1
)[
1
]
fgraph
=
gof
.
FunctionGraph
(
fgraph
=
gof
.
FunctionGraph
(
[
x
],
[
x
],
...
@@ -1147,7 +1147,7 @@ def test_argmax_pushdown():
...
@@ -1147,7 +1147,7 @@ def test_argmax_pushdown():
x
=
tensor
.
matrix
()
x
=
tensor
.
matrix
()
# test that the max_and_argmax is not pushed down if the max is used
# test that the max_and_argmax is not pushed down if the max is used
out
=
tensor
.
max_and_argmax
(
out
=
tensor
.
max_and_argmax
(
softmax
(
tensor
.
exp
(
tensor
.
tanh
(
sigmoid
(
x
)))),
softmax
_op
(
tensor
.
exp
(
tensor
.
tanh
(
sigmoid
(
x
)))),
axis
=-
1
)[
0
]
axis
=-
1
)[
0
]
fgraph
=
gof
.
FunctionGraph
(
fgraph
=
gof
.
FunctionGraph
(
[
x
],
[
x
],
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论