Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7dd20e1d
提交
7dd20e1d
authored
12月 02, 2013
作者:
vdumoulin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1 from nouiz/vdumoulin-new_backend
Vdumoulin new backend
上级
024347f9
ab250493
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
26 行增加
和
20 行删除
+26
-20
nnet.py
theano/sandbox/gpuarray/nnet.py
+0
-0
opt.py
theano/sandbox/gpuarray/opt.py
+3
-3
test_nnet.py
theano/sandbox/gpuarray/tests/test_nnet.py
+16
-16
type.py
theano/sandbox/gpuarray/type.py
+7
-1
没有找到文件。
theano/sandbox/gpuarray/nnet.py
浏览文件 @
7dd20e1d
差异被折叠。
点击展开。
theano/sandbox/gpuarray/opt.py
浏览文件 @
7dd20e1d
...
...
@@ -60,7 +60,6 @@ def op_lifter(OP):
def
local_opt
(
node
):
if
type
(
node
.
op
)
in
OP
:
# This does not support nodes that have more than one output.
assert
len
(
node
.
outputs
)
==
1
# either one of our inputs is on the gpu or
# all of our client are on the gpu
if
(
any
([
i
.
owner
and
i
.
owner
.
op
==
host_from_gpu
...
...
@@ -71,7 +70,9 @@ def op_lifter(OP):
# This is needed as sometimes new_op inherit from OP.
if
new_op
and
new_op
!=
node
.
op
:
if
isinstance
(
new_op
,
theano
.
Op
):
return
[
host_from_gpu
(
new_op
(
*
node
.
inputs
))]
return
[
host_from_gpu
(
o
)
for
o
in
new_op
(
*
node
.
inputs
,
return_list
=
True
)]
elif
isinstance
(
new_op
,
(
tuple
,
list
)):
return
[
host_from_gpu
(
o
)
for
o
in
new_op
]
else
:
# suppose it is a variable on the GPU
return
[
host_from_gpu
(
new_op
)]
return
False
...
...
@@ -281,4 +282,3 @@ def local_gpua_crossentropysoftmaxargmax1hotwithbias(node):
@op_lifter
([
tensor
.
nnet
.
CrossentropySoftmax1HotWithBiasDx
])
def
local_gpua_crossentropysoftmax1hotwithbiasdx
(
node
):
return
GpuCrossentropySoftmax1HotWithBiasDx
()
theano/sandbox/gpuarray/tests/test_nnet.py
浏览文件 @
7dd20e1d
...
...
@@ -6,7 +6,7 @@ from theano.gof.python25 import any
import
theano.tensor
as
T
import
theano.tests.unittest_tools
as
utt
import
theano.sandbox.
gpuarray
from
theano.sandbox
import
gpuarray
if
theano
.
sandbox
.
gpuarray
.
pygpu
is
None
:
raise
SkipTest
(
"pygpu not installed"
)
...
...
@@ -20,21 +20,21 @@ if cuda_ndarray.cuda_available and not theano.sandbox.gpuarray.pygpu_activated:
default_to_move_computation_to_gpu
=
False
,
move_shared_float32_to_gpu
=
False
,
enable_cuda
=
False
)
theano
.
sandbox
.
gpuarray
.
init_dev
(
'cuda'
)
gpuarray
.
init_dev
(
'cuda'
)
if
not
theano
.
sandbox
.
gpuarray
.
pygpu_activated
:
if
not
gpuarray
.
pygpu_activated
:
raise
SkipTest
(
"pygpu disabled"
)
from
theano.sandbox.gpuarray.nnet
import
(
GpuCrossentropySoftmaxArgmax1HotWithBias
,
GpuCrossentropySoftmax1HotWithBiasDx
)
from
theano.sandbox.gpuarray.nnet
import
(
GpuCrossentropySoftmaxArgmax1HotWithBias
,
GpuCrossentropySoftmax1HotWithBiasDx
)
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
mode_with_gpu
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
.
including
(
'gpu'
)
mode_without_gpu
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
.
excluding
(
'gpu'
)
mode_with_gpu
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
.
including
(
'gpuarray'
)
.
excluding
(
'gpu'
)
mode_without_gpu
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
.
excluding
(
'gpuarray'
)
else
:
mode_with_gpu
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
'gpu'
)
mode_without_gpu
=
theano
.
compile
.
mode
.
get_default_mode
()
.
excluding
(
'gpu'
)
mode_with_gpu
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
'gpu
array'
)
.
excluding
(
'gpu
'
)
mode_without_gpu
=
theano
.
compile
.
mode
.
get_default_mode
()
.
excluding
(
'gpu
array
'
)
def
test_GpuCrossentropySoftmaxArgmax1HotWithBias
():
...
...
@@ -87,7 +87,7 @@ def test_GpuCrossentropySoftmaxArgmax1HotWithBias():
mode
=
mode_without_gpu
)
classify_gpu
=
theano
.
function
(
inputs
=
[
y
,
b
,
dot_result
],
outputs
=
[
loss
,
y_pred
,
dW
],
mode
=
mode_with_gpu
)
mode
=
mode_with_gpu
)
#theano.printing.debugprint(classify)
#theano.printing.debugprint(classify_gpu)
...
...
@@ -95,7 +95,7 @@ def test_GpuCrossentropySoftmaxArgmax1HotWithBias():
T
.
nnet
.
CrossentropySoftmaxArgmax1HotWithBias
)
for
node
in
classify
.
maker
.
fgraph
.
toposort
()])
assert
any
([
isinstance
(
node
.
op
,
theano
.
sandbox
.
gpuarray
.
nnet
.
GpuCrossentropySoftmaxArgmax1HotWithBias
)
GpuCrossentropySoftmaxArgmax1HotWithBias
)
for
node
in
classify_gpu
.
maker
.
fgraph
.
toposort
()])
out
=
classify
(
yy
,
b_values
,
dot_value
)
...
...
@@ -104,7 +104,7 @@ def test_GpuCrossentropySoftmaxArgmax1HotWithBias():
assert
len
(
out
)
==
len
(
gout
)
==
3
assert
numpy
.
allclose
(
out
[
0
],
gout
[
0
])
assert
numpy
.
allclose
(
out
[
2
],
gout
[
2
],
atol
=
3e-6
),
numpy
.
absolute
(
gout
-
out
)
.
max
()
gout
[
2
]
-
out
[
2
]
)
.
max
()
assert
numpy
.
allclose
(
out
[
1
],
gout
[
1
]),
[(
id
,
out
[
1
][
id
],
gout
[
1
][
id
],
val
)
for
id
,
val
in
enumerate
(
out
[
1
]
-
gout
[
1
])
...
...
@@ -150,7 +150,7 @@ def test_GpuCrossentropySoftmax1HotWithBiasDx():
assert
any
([
isinstance
(
node
.
op
,
T
.
nnet
.
CrossentropySoftmax1HotWithBiasDx
)
for
node
in
cpu_f
.
maker
.
fgraph
.
toposort
()])
assert
any
([
isinstance
(
node
.
op
,
theano
.
sandbox
.
gpuarray
.
nnet
.
GpuCrossentropySoftmax1HotWithBiasDx
)
GpuCrossentropySoftmax1HotWithBiasDx
)
for
node
in
gpu_f
.
maker
.
fgraph
.
toposort
()])
cpu_out
=
cpu_f
(
softmax_output_value
)
...
...
@@ -164,7 +164,7 @@ def test_GpuCrossentropySoftmax1HotWithBiasDx():
max_i
=
scaled_err
.
argmax
()
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
'err:'
,
scaled_err
.
flatten
()[
max_i
]
print
'absolute error:'
,
abs_err
.
flatten
()[
max_i
]
...
...
@@ -176,4 +176,4 @@ def test_GpuCrossentropySoftmax1HotWithBiasDx():
print
'y_idx_value:'
,
y_idx_value
[
max_i
/
n_out
]
assert
False
,
"numpy.allclose(cpu_out, gpu_out, rtol=
%
s, atol=
%
s)"
%
(
rtol
,
atol
)
rtol
,
atol
)
theano/sandbox/gpuarray/type.py
浏览文件 @
7dd20e1d
...
...
@@ -138,7 +138,13 @@ class GpuArrayType(Type):
return
numpy
.
dtype
(
self
.
dtype
)
.
itemsize
def
c_declare
(
self
,
name
,
sub
):
return
"PyGpuArrayObject *
%
s;"
%
(
name
,)
dtype
=
theano
.
tensor
.
TensorType
(
dtype
=
self
.
dtype
,
broadcastable
=
self
.
broadcastable
)
.
dtype_specs
()[
1
]
return
"""
PyGpuArrayObject *
%(name)
s;
typedef
%(dtype)
s dtype_
%(name)
s;
"""
%
locals
()
def
c_init
(
self
,
name
,
sub
):
return
"
%
s = NULL;"
%
(
name
,)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论