Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9f8512d2
提交
9f8512d2
authored
6月 28, 2017
作者:
João Victor Tozatti Risso
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tranpose image to NCHW in order to test with spatialtf
Signed-off-by:
João Victor Tozatti Risso
<
joaovictor.risso@gmail.com
>
上级
278d5e8d
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
12 行增加
和
7 行删除
+12
-7
test_dnn.py
theano/gpuarray/tests/test_dnn.py
+12
-7
没有找到文件。
theano/gpuarray/tests/test_dnn.py
浏览文件 @
9f8512d2
...
...
@@ -2305,17 +2305,18 @@ def test_dnn_spatialtf_grid_generator():
raise
SkipTest
(
dnn
.
dnn_available
.
msg
)
utt
.
seed_rng
()
# shape: (num_images,
height, width, num_channels)
grid_dims
=
(
2
,
64
,
64
,
3
)
# shape: (num_images,
channels, height, width), equivalent to NCHW
grid_dims
=
(
10
,
3
,
64
,
128
)
identity
=
[[
1
,
0
,
0
],
[
0
,
1
,
0
]]
identity
=
[[
1
,
0
,
0
],
[
0
,
1
,
0
]]
theta
=
np
.
asarray
(
[
identity
,
identity
],
dtype
=
theano
.
config
.
floatX
)
theta
=
np
.
asarray
(
grid_dims
[
0
]
*
[
identity
],
dtype
=
theano
.
config
.
floatX
)
theta_gpu
=
gpuarray_shared_constructor
(
theta
)
from
scipy
import
misc
f
=
misc
.
face
()
.
astype
(
np
.
float32
)
f
=
np
.
transpose
(
f
,
axes
=
(
2
,
0
,
1
))
# Scale input from [0, 255] to [0, 2]
sc
=
1.
/
128.
f
*=
sc
...
...
@@ -2323,7 +2324,7 @@ def test_dnn_spatialtf_grid_generator():
f
-=
1
# Create array of images
img
=
np
.
asarray
(
[
f
,
f
],
dtype
=
theano
.
config
.
floatX
)
img
=
np
.
asarray
(
grid_dims
[
0
]
*
[
f
],
dtype
=
theano
.
config
.
floatX
)
# Create GPU variable for the images
img_gpu
=
gpuarray_shared_constructor
(
img
)
...
...
@@ -2335,12 +2336,15 @@ def test_dnn_spatialtf_grid_generator():
img_out
=
np
.
asarray
(
result
,
dtype
=
np
.
float32
)
print
(
img_out
.
shape
)
for
i
in
range
(
len
(
img_out
)):
# Re-scale output to range [0, 2]
img_out
[
i
]
+=
1
# Re-scale output to range [0, 255]
img_out
[
i
]
*=
128
img_out
=
img_out
.
astype
(
dtype
=
np
.
uint8
)
img_out
=
np
.
transpose
(
img_out
,
axes
=
(
0
,
2
,
3
,
1
))
for
i
in
range
(
len
(
img_out
)):
print
(
"[sampled image #{0}]"
.
format
(
i
))
...
...
@@ -2353,4 +2357,5 @@ def test_dnn_spatialtf_grid_generator():
plt
.
show
()
topo
=
spatialtf_fn
.
maker
.
fgraph
.
toposort
()
assert
len
([
n
for
n
in
topo
if
isinstance
(
n
.
op
,
dnn
.
GpuDnnGridGeneratorOp
)])
==
1
assert
len
([
n
for
n
in
topo
if
isinstance
(
n
.
op
,
dnn
.
GpuDnnGridGenerator
)])
==
1
assert
len
([
n
for
n
in
topo
if
isinstance
(
n
.
op
,
dnn
.
GpuDnnGridSampler
)])
==
1
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论