Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5534d3ca
提交
5534d3ca
authored
12月 02, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pep8
上级
eb49be66
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
7 行删除
+11
-7
test_nnet.py
theano/sandbox/gpuarray/tests/test_nnet.py
+11
-7
没有找到文件。
theano/sandbox/gpuarray/tests/test_nnet.py
浏览文件 @
5534d3ca
...
@@ -7,6 +7,9 @@ import theano.tensor as T
...
@@ -7,6 +7,9 @@ import theano.tensor as T
import
theano.tests.unittest_tools
as
utt
import
theano.tests.unittest_tools
as
utt
from
theano.sandbox
import
gpuarray
from
theano.sandbox
import
gpuarray
from
theano.sandbox.gpuarray.nnet
import
(
GpuCrossentropySoftmaxArgmax1HotWithBias
,
GpuCrossentropySoftmax1HotWithBiasDx
)
if
theano
.
sandbox
.
gpuarray
.
pygpu
is
None
:
if
theano
.
sandbox
.
gpuarray
.
pygpu
is
None
:
raise
SkipTest
(
"pygpu not installed"
)
raise
SkipTest
(
"pygpu not installed"
)
...
@@ -25,8 +28,9 @@ if cuda_ndarray.cuda_available and not theano.sandbox.gpuarray.pygpu_activated:
...
@@ -25,8 +28,9 @@ if cuda_ndarray.cuda_available and not theano.sandbox.gpuarray.pygpu_activated:
if
not
gpuarray
.
pygpu_activated
:
if
not
gpuarray
.
pygpu_activated
:
raise
SkipTest
(
"pygpu disabled"
)
raise
SkipTest
(
"pygpu disabled"
)
from
theano.sandbox.gpuarray.nnet
import
(
GpuCrossentropySoftmaxArgmax1HotWithBias
,
from
theano.sandbox.gpuarray.nnet
import
(
GpuCrossentropySoftmax1HotWithBiasDx
)
GpuCrossentropySoftmaxArgmax1HotWithBias
,
GpuCrossentropySoftmax1HotWithBiasDx
)
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
mode_with_gpu
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
.
including
(
'gpuarray'
)
.
excluding
(
'gpu'
)
mode_with_gpu
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
.
including
(
'gpuarray'
)
.
excluding
(
'gpu'
)
...
@@ -86,7 +90,7 @@ def test_GpuCrossentropySoftmaxArgmax1HotWithBias():
...
@@ -86,7 +90,7 @@ def test_GpuCrossentropySoftmaxArgmax1HotWithBias():
mode
=
mode_without_gpu
)
mode
=
mode_without_gpu
)
classify_gpu
=
theano
.
function
(
inputs
=
[
y
,
b
,
dot_result
],
classify_gpu
=
theano
.
function
(
inputs
=
[
y
,
b
,
dot_result
],
outputs
=
[
loss
,
y_pred
,
dW
],
outputs
=
[
loss
,
y_pred
,
dW
],
mode
=
mode_with_gpu
)
mode
=
mode_with_gpu
)
#theano.printing.debugprint(classify)
#theano.printing.debugprint(classify)
#theano.printing.debugprint(classify_gpu)
#theano.printing.debugprint(classify_gpu)
...
@@ -94,7 +98,7 @@ def test_GpuCrossentropySoftmaxArgmax1HotWithBias():
...
@@ -94,7 +98,7 @@ def test_GpuCrossentropySoftmaxArgmax1HotWithBias():
T
.
nnet
.
CrossentropySoftmaxArgmax1HotWithBias
)
T
.
nnet
.
CrossentropySoftmaxArgmax1HotWithBias
)
for
node
in
classify
.
maker
.
fgraph
.
toposort
()])
for
node
in
classify
.
maker
.
fgraph
.
toposort
()])
assert
any
([
isinstance
(
node
.
op
,
assert
any
([
isinstance
(
node
.
op
,
gpuarray
.
nnet
.
GpuCrossentropySoftmaxArgmax1HotWithBias
)
GpuCrossentropySoftmaxArgmax1HotWithBias
)
for
node
in
classify_gpu
.
maker
.
fgraph
.
toposort
()])
for
node
in
classify_gpu
.
maker
.
fgraph
.
toposort
()])
out
=
classify
(
yy
,
b_values
,
dot_value
)
out
=
classify
(
yy
,
b_values
,
dot_value
)
...
@@ -149,7 +153,7 @@ def test_GpuCrossentropySoftmax1HotWithBiasDx():
...
@@ -149,7 +153,7 @@ def test_GpuCrossentropySoftmax1HotWithBiasDx():
assert
any
([
isinstance
(
node
.
op
,
T
.
nnet
.
CrossentropySoftmax1HotWithBiasDx
)
assert
any
([
isinstance
(
node
.
op
,
T
.
nnet
.
CrossentropySoftmax1HotWithBiasDx
)
for
node
in
cpu_f
.
maker
.
fgraph
.
toposort
()])
for
node
in
cpu_f
.
maker
.
fgraph
.
toposort
()])
assert
any
([
isinstance
(
node
.
op
,
assert
any
([
isinstance
(
node
.
op
,
gpuarray
.
nnet
.
GpuCrossentropySoftmax1HotWithBiasDx
)
GpuCrossentropySoftmax1HotWithBiasDx
)
for
node
in
gpu_f
.
maker
.
fgraph
.
toposort
()])
for
node
in
gpu_f
.
maker
.
fgraph
.
toposort
()])
cpu_out
=
cpu_f
(
softmax_output_value
)
cpu_out
=
cpu_f
(
softmax_output_value
)
...
@@ -163,7 +167,7 @@ def test_GpuCrossentropySoftmax1HotWithBiasDx():
...
@@ -163,7 +167,7 @@ def test_GpuCrossentropySoftmax1HotWithBiasDx():
max_i
=
scaled_err
.
argmax
()
max_i
=
scaled_err
.
argmax
()
print
'max err index:'
,
max_i
,
max_i
/
batch_size
,
print
'max err index:'
,
max_i
,
max_i
/
batch_size
,
print
max_i
%
batch_size
,
max_i
/
n_out
,
max_i
&
n_out
print
max_i
%
batch_size
,
max_i
/
n_out
,
max_i
&
n_out
print
'At that index:'
print
'At that index:'
print
'err:'
,
scaled_err
.
flatten
()[
max_i
]
print
'err:'
,
scaled_err
.
flatten
()[
max_i
]
print
'absolute error:'
,
abs_err
.
flatten
()[
max_i
]
print
'absolute error:'
,
abs_err
.
flatten
()[
max_i
]
...
@@ -175,4 +179,4 @@ def test_GpuCrossentropySoftmax1HotWithBiasDx():
...
@@ -175,4 +179,4 @@ def test_GpuCrossentropySoftmax1HotWithBiasDx():
print
'y_idx_value:'
,
y_idx_value
[
max_i
/
n_out
]
print
'y_idx_value:'
,
y_idx_value
[
max_i
/
n_out
]
assert
False
,
"numpy.allclose(cpu_out, gpu_out, rtol=
%
s, atol=
%
s)"
%
(
assert
False
,
"numpy.allclose(cpu_out, gpu_out, rtol=
%
s, atol=
%
s)"
%
(
rtol
,
atol
)
rtol
,
atol
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论