Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fa436a06
提交
fa436a06
authored
9月 25, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add some missing tests and fix small mistakes.
上级
fdde035a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
65 行增加
和
31 行删除
+65
-31
dnn.py
theano/sandbox/gpuarray/dnn.py
+2
-2
test_dnn.py
theano/sandbox/gpuarray/tests/test_dnn.py
+63
-29
没有找到文件。
theano/sandbox/gpuarray/dnn.py
浏览文件 @
fa436a06
...
...
@@ -264,9 +264,9 @@ class GpuDnnConvDesc(COp):
pad2
=
str
(
self
.
border_mode
[
2
])
bmode
=
'2'
elif
self
.
border_mode
==
"valid"
:
bmode
=
1
bmode
=
'1'
elif
self
.
border_mode
==
"full"
:
bmode
=
0
bmode
=
'0'
else
:
raise
ValueError
(
"Invalid value for border_mode"
)
...
...
theano/sandbox/gpuarray/tests/test_dnn.py
浏览文件 @
fa436a06
...
...
@@ -692,7 +692,7 @@ class test_SoftMax(test_nnet.test_SoftMax):
mode
=
mode_with_gpu
def
test_softmax_shape_0
(
self
):
raise
SkipTest
(
"Cudnn doesn't suport 0 shapes"
)
raise
SkipTest
(
"Cudnn doesn't sup
p
ort 0 shapes"
)
def
test_softmax_grad
(
self
):
def
cmp
(
n
,
m
,
f
,
f_gpu
):
...
...
@@ -745,20 +745,18 @@ class test_SoftMax(test_nnet.test_SoftMax):
mode
=
mode_with_gpu
)
sorted_f
=
f
.
maker
.
fgraph
.
toposort
()
# Optimization is disabled for cudnn v3 rc1
if
dnn
.
version
()
==
2000
:
assert
(
len
([
i
for
i
in
sorted_f
if
isinstance
(
i
.
op
,
self
.
gpu_grad_op
)
])
==
1
)
assert
(
len
([
i
for
i
in
sorted_f
if
isinstance
(
i
.
op
,
theano
.
tensor
.
nnet
.
SoftmaxGrad
)
])
==
0
)
assert
(
len
([
i
for
i
in
sorted_f
if
isinstance
(
i
.
op
,
self
.
gpu_grad_op
)
])
==
1
)
assert
(
len
([
i
for
i
in
sorted_f
if
isinstance
(
i
.
op
,
theano
.
tensor
.
nnet
.
SoftmaxGrad
)
])
==
0
)
# Verify that the SoftmaxGrad -> Gpu[Dnn]SoftmaxGrad
# optimization is not applied when cudnn is excluded or not
...
...
@@ -790,17 +788,53 @@ class test_SoftMax(test_nnet.test_SoftMax):
o
=
theano
.
tensor
.
nnet
.
SoftmaxGrad
()(
y
,
y
*
2
)
f
=
theano
.
function
([
y
],
o
,
mode
=
mode_with_gpu
)
sorted_f
=
f
.
maker
.
fgraph
.
toposort
()
if
dnn
.
version
()
==
2000
:
# opt disabled for cudnn v3 rc1
assert
(
len
([
i
for
i
in
sorted_f
if
isinstance
(
i
.
op
,
self
.
gpu_grad_op
)
])
==
1
)
assert
(
len
([
i
for
i
in
sorted_f
if
isinstance
(
i
.
op
,
theano
.
tensor
.
nnet
.
SoftmaxGrad
)
])
==
0
)
assert
(
len
([
i
for
i
in
sorted_f
if
isinstance
(
i
.
op
,
self
.
gpu_grad_op
)
])
==
1
)
assert
(
len
([
i
for
i
in
sorted_f
if
isinstance
(
i
.
op
,
theano
.
tensor
.
nnet
.
SoftmaxGrad
)
])
==
0
)
def
test_log_softmax
(
self
):
# This is a test for an optimization that depends on CuDNN v3 or
# more recent. Don't test if the CuDNN version is too old.
if
dnn
.
version
()
<
3000
:
raise
SkipTest
(
"Log-softmax is only in cudnn v3+"
)
x
=
T
.
ftensor4
()
softmax_out
=
dnn
.
GpuDnnSoftmax
(
'bc01'
,
'accurate'
,
'channel'
)(
x
)
log_out
=
T
.
log
(
T
.
as_tensor_variable
(
softmax_out
))
f
=
theano
.
function
([
x
],
log_out
,
mode
=
mode_with_gpu
)
# Ensure that the optimization has been applied
dnn_softmax_nodes
=
[
n
for
n
in
f
.
maker
.
fgraph
.
toposort
()
if
isinstance
(
n
.
op
,
dnn
.
GpuDnnSoftmax
)]
assert
len
(
dnn_softmax_nodes
)
==
1
assert
dnn_softmax_nodes
[
0
]
.
op
.
algo
==
"log"
# Ensure that the output of the function is valid
input_shapes
=
[(
3
,
4
,
5
,
6
),
(
1025
,
2
,
3
,
4
),
(
2
,
1025
,
3
,
4
),
(
2
,
3
,
1025
,
4
),
(
2
,
3
,
4
,
1025
),
(
66000
,
2
,
3
,
4
),
(
2
,
66000
,
3
,
4
),
(
2
,
3
,
66000
,
4
),
(
2
,
3
,
4
,
66000
)]
for
inp_shape
in
input_shapes
:
input_val
=
numpy
.
random
.
normal
(
0
,
1
,
inp_shape
)
.
astype
(
"float32"
)
out
=
f
(
input_val
)
expected_out
=
numpy
.
log
(
numpy
.
exp
(
input_val
)
/
numpy
.
exp
(
input_val
)
.
sum
(
1
)[:,
None
,
:,
:])
utt
.
assert_allclose
(
out
,
expected_out
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论