Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5d767fbb
提交
5d767fbb
authored
9月 26, 2014
作者:
Amjad Almahairi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
improving the code for fixing ticket 1356
上级
f6689bbe
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
9 行增加
和
7 行删除
+9
-7
using_gpu_solution_1.py
doc/tutorial/using_gpu_solution_1.py
+9
-7
没有找到文件。
doc/tutorial/using_gpu_solution_1.py
浏览文件 @
5d767fbb
...
@@ -28,8 +28,8 @@ rng.randint(size=N, low=0, high=2).astype(theano.config.floatX))
...
@@ -28,8 +28,8 @@ rng.randint(size=N, low=0, high=2).astype(theano.config.floatX))
training_steps
=
10000
training_steps
=
10000
# Declare Theano symbolic variables
# Declare Theano symbolic variables
x
=
t
t
.
matrix
(
"x"
)
x
=
t
heano
.
shared
(
D
[
0
],
name
=
"x"
)
y
=
t
t
.
vector
(
"y"
)
y
=
t
heano
.
shared
(
D
[
1
],
name
=
"y"
)
w
=
theano
.
shared
(
rng
.
randn
(
feats
)
.
astype
(
theano
.
config
.
floatX
),
name
=
"w"
)
w
=
theano
.
shared
(
rng
.
randn
(
feats
)
.
astype
(
theano
.
config
.
floatX
),
name
=
"w"
)
b
=
theano
.
shared
(
numpy
.
asarray
(
0.
,
dtype
=
theano
.
config
.
floatX
),
name
=
"b"
)
b
=
theano
.
shared
(
numpy
.
asarray
(
0.
,
dtype
=
theano
.
config
.
floatX
),
name
=
"b"
)
x
.
tag
.
test_value
=
D
[
0
]
x
.
tag
.
test_value
=
D
[
0
]
...
@@ -58,11 +58,11 @@ predict = theano.function(inputs=[x], outputs=Out(theano.sandbox.cuda.basic_ops.
...
@@ -58,11 +58,11 @@ predict = theano.function(inputs=[x], outputs=Out(theano.sandbox.cuda.basic_ops.
# Compile expressions to functions
# Compile expressions to functions
train
=
theano
.
function
(
train
=
theano
.
function
(
inputs
=
[
x
,
y
],
inputs
=
[],
outputs
=
[
prediction
,
xent
],
outputs
=
[
prediction
,
xent
],
updates
=
{
w
:
w
-
0.01
*
gw
,
b
:
b
-
0.01
*
gb
},
updates
=
{
w
:
w
-
0.01
*
gw
,
b
:
b
-
0.01
*
gb
},
name
=
"train"
)
name
=
"train"
)
predict
=
theano
.
function
(
inputs
=
[
x
],
outputs
=
prediction
,
predict
=
theano
.
function
(
inputs
=
[],
outputs
=
prediction
,
name
=
"predict"
)
name
=
"predict"
)
if
any
([
x
.
op
.
__class__
.
__name__
in
[
'Gemv'
,
'CGemv'
,
'Gemm'
,
'CGemm'
]
for
x
in
if
any
([
x
.
op
.
__class__
.
__name__
in
[
'Gemv'
,
'CGemv'
,
'Gemm'
,
'CGemm'
]
for
x
in
...
@@ -76,7 +76,7 @@ else:
...
@@ -76,7 +76,7 @@ else:
print
train
.
maker
.
fgraph
.
toposort
()
print
train
.
maker
.
fgraph
.
toposort
()
for
i
in
range
(
training_steps
):
for
i
in
range
(
training_steps
):
pred
,
err
=
train
(
D
[
0
],
D
[
1
]
)
pred
,
err
=
train
()
#print "Final model:"
#print "Final model:"
#print w.get_value(), b.get_value()
#print w.get_value(), b.get_value()
...
@@ -84,7 +84,7 @@ print "target values for D"
...
@@ -84,7 +84,7 @@ print "target values for D"
print
D
[
1
]
print
D
[
1
]
print
"prediction on D"
print
"prediction on D"
print
predict
(
D
[
0
]
)
print
predict
()
"""
"""
...
@@ -308,7 +308,9 @@ Test them first, as they are not guaranteed to always provide a speedup.
...
@@ -308,7 +308,9 @@ Test them first, as they are not guaranteed to always provide a speedup.
Facts:
Facts:
Examine and compare 'Single Op-wise' summaries for CPU and GPU. GPU ops 'GpuFromHost' (and 'HostFromGpu') by themselves
Examine and compare 'Single Op-wise' summaries for CPU and GPU. GPU ops 'GpuFromHost' (and 'HostFromGpu') by themselves
consume a large amount of extra time. Furthermore, notice that each of the GPU ops consumes more time than its CPU counterpart.
consume a large amount of extra time, but by making as few as possible data transfers between GPU and CPU, you can minimize its overhead.
In addition, you probably need to increase the input data size (e.g. set N = 4000) to see the gain of the GPU.
Furthermore, notice that each of the GPU ops consumes more time than its CPU counterpart.
An additional experiment also confirms that adding an 'out' instance in the GPU version only brings about a minor
An additional experiment also confirms that adding an 'out' instance in the GPU version only brings about a minor
improvement in this situation.
improvement in this situation.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论