Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c32b0db8
提交
c32b0db8
authored
8月 25, 2017
作者:
Frédéric Bastien
提交者:
GitHub
8月 25, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6357 from gvtulder/f-gpuarray-spatialtf-shape
Check shapes of spatial transform theta parameters
上级
1bc17311
7ba18c97
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
39 行增加
和
9 行删除
+39
-9
dnn_sptf_grid.c
theano/gpuarray/c_code/dnn_sptf_grid.c
+10
-9
test_dnn.py
theano/gpuarray/tests/test_dnn.py
+29
-0
没有找到文件。
theano/gpuarray/c_code/dnn_sptf_grid.c
浏览文件 @
c32b0db8
...
...
@@ -53,15 +53,6 @@ APPLY_SPECIFIC(dnn_sptf_grid)(PyGpuArrayObject * theta,
return
1
;
}
if
(
PyGpuArray_DIM
(
theta
,
1
)
!=
2
||
PyGpuArray_DIM
(
theta
,
2
)
!=
3
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"GpuDnnTransformerGrid: incorrect dimensions for theta, expected (%d, %d, %d), got (%d, %d, %d)"
,
PyGpuArray_DIMS
(
theta
)[
0
],
2
,
3
,
PyGpuArray_DIMS
(
theta
)[
0
],
PyGpuArray_DIMS
(
theta
)[
1
],
PyGpuArray_DIMS
(
theta
)[
2
]
);
return
1
;
}
if
(
PyArray_NDIM
(
out_dims
)
!=
1
||
PyArray_SIZE
(
out_dims
)
!=
4
)
{
PyErr_SetString
(
PyExc_MemoryError
,
...
...
@@ -75,6 +66,16 @@ APPLY_SPECIFIC(dnn_sptf_grid)(PyGpuArrayObject * theta,
height
=
(
int
)
*
(
(
npy_int64
*
)
PyArray_GETPTR1
(
out_dims
,
2
)
);
width
=
(
int
)
*
(
(
npy_int64
*
)
PyArray_GETPTR1
(
out_dims
,
3
)
);
if
(
PyGpuArray_DIM
(
theta
,
0
)
!=
num_images
||
PyGpuArray_DIM
(
theta
,
1
)
!=
2
||
PyGpuArray_DIM
(
theta
,
2
)
!=
3
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"GpuDnnTransformerGrid: incorrect dimensions for theta, expected (%d, %d, %d), got (%d, %d, %d)"
,
num_images
,
2
,
3
,
PyGpuArray_DIMS
(
theta
)[
0
],
PyGpuArray_DIMS
(
theta
)[
1
],
PyGpuArray_DIMS
(
theta
)[
2
]
);
return
1
;
}
// Set transformed output dimensions to setup the descriptor
desc_dims
[
0
]
=
num_images
;
desc_dims
[
1
]
=
num_channels
;
...
...
theano/gpuarray/tests/test_dnn.py
浏览文件 @
c32b0db8
...
...
@@ -3,6 +3,7 @@ import logging
from
collections
import
OrderedDict
from
nose.plugins.skip
import
SkipTest
from
nose.tools
import
assert_raises
from
parameterized
import
parameterized
import
numpy
as
np
from
itertools
import
product
,
chain
...
...
@@ -2470,6 +2471,34 @@ def test_dnn_spatialtf():
utt
.
assert_allclose
(
img_out_cpu
,
img_out_gpu
,
atol
=
atol
,
rtol
=
rtol
)
def
test_dnn_spatialtf_invalid_shapes
():
if
not
dnn
.
dnn_available
(
test_ctx_name
):
raise
SkipTest
(
dnn
.
dnn_available
.
msg
)
inputs
=
T
.
tensor4
(
'inputs'
)
theta
=
T
.
tensor3
(
'theta'
)
st_dnn
=
dnn
.
dnn_spatialtf
(
inputs
,
theta
)
st_dnn_func
=
theano
.
function
([
inputs
,
theta
],
st_dnn
)
inputs_val
=
np
.
ones
((
3
,
5
,
7
,
7
),
dtype
=
theano
.
config
.
floatX
)
def
try_theta_shp
(
theta_shp
):
theta_val
=
np
.
ones
(
theta_shp
,
dtype
=
theano
.
config
.
floatX
)
return
st_dnn_func
(
inputs_val
,
theta_val
)
# the theta shape for this input should be (3, 2, 3)
try_theta_shp
((
3
,
2
,
3
))
# incorrect parameter dimensions
assert_raises
(
RuntimeError
,
try_theta_shp
,
(
3
,
1
,
3
))
assert_raises
(
RuntimeError
,
try_theta_shp
,
(
3
,
2
,
1
))
# number of rows does not match the number of input rows
assert_raises
(
RuntimeError
,
try_theta_shp
,
(
1
,
2
,
3
))
assert_raises
(
RuntimeError
,
try_theta_shp
,
(
4
,
2
,
3
))
def
test_dnn_spatialtf_grad
():
if
not
dnn
.
dnn_available
(
test_ctx_name
):
raise
SkipTest
(
dnn
.
dnn_available
.
msg
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论