Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
be7298eb
提交
be7298eb
authored
5月 05, 2013
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PEP8
上级
9b24aa75
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
21 行增加
和
19 行删除
+21
-19
test_tutorial.py
theano/tests/test_tutorial.py
+21
-19
没有找到文件。
theano/tests/test_tutorial.py
浏览文件 @
be7298eb
...
@@ -844,10 +844,9 @@ class T_using_gpu(unittest.TestCase):
...
@@ -844,10 +844,9 @@ class T_using_gpu(unittest.TestCase):
assert
not
numpy
.
any
([
isinstance
(
x
.
op
,
T
.
Elemwise
)
for
x
in
f
.
maker
.
fgraph
.
toposort
()])
assert
not
numpy
.
any
([
isinstance
(
x
.
op
,
T
.
Elemwise
)
for
x
in
f
.
maker
.
fgraph
.
toposort
()])
def
test_using_gpu_3
(
self
):
def
test_using_gpu_3
(
self
):
if
theano
.
config
.
device
.
find
(
'gpu'
)
>-
1
:
if
theano
.
config
.
device
.
find
(
'gpu'
)
>
-
1
:
from
theano
import
function
,
config
,
shared
,
sandbox
,
Out
from
theano
import
function
,
config
,
shared
,
sandbox
,
Out
import
theano.tensor
as
T
import
theano.tensor
as
T
...
@@ -870,12 +869,14 @@ class T_using_gpu(unittest.TestCase):
...
@@ -870,12 +869,14 @@ class T_using_gpu(unittest.TestCase):
print
'Looping
%
d times took'
%
iters
,
t1
-
t0
,
'seconds'
print
'Looping
%
d times took'
%
iters
,
t1
-
t0
,
'seconds'
print
'Result is'
,
r
print
'Result is'
,
r
print
'Numpy result is'
,
numpy
.
asarray
(
r
)
print
'Numpy result is'
,
numpy
.
asarray
(
r
)
if
numpy
.
any
([
isinstance
(
x
.
op
,
T
.
Elemwise
)
for
x
in
f
.
maker
.
fgraph
.
toposort
()]):
if
numpy
.
any
([
isinstance
(
x
.
op
,
T
.
Elemwise
)
for
x
in
f
.
maker
.
fgraph
.
toposort
()]):
print
'Used the cpu'
print
'Used the cpu'
else
:
else
:
print
'Used the gpu'
print
'Used the gpu'
assert
not
numpy
.
any
([
isinstance
(
x
.
op
,
T
.
Elemwise
)
for
x
in
f
.
maker
.
fgraph
.
toposort
()])
assert
not
numpy
.
any
([
isinstance
(
x
.
op
,
T
.
Elemwise
)
for
x
in
f
.
maker
.
fgraph
.
toposort
()])
class
T_fibby
(
unittest
.
TestCase
):
class
T_fibby
(
unittest
.
TestCase
):
...
@@ -904,13 +905,14 @@ class T_fibby(unittest.TestCase):
...
@@ -904,13 +905,14 @@ class T_fibby(unittest.TestCase):
return
theano
.
Apply
(
self
,
return
theano
.
Apply
(
self
,
inputs
=
[
x_
],
inputs
=
[
x_
],
outputs
=
[
x_
.
type
()])
outputs
=
[
x_
.
type
()])
# using x_.type() is dangerous, it copies x's broadcasting behaviour
# using x_.type() is dangerous, it copies x's broadcasting
# behaviour
def
perform
(
self
,
node
,
inputs
,
output_storage
):
def
perform
(
self
,
node
,
inputs
,
output_storage
):
x
,
=
inputs
x
,
=
inputs
y
=
output_storage
[
0
][
0
]
=
x
.
copy
()
y
=
output_storage
[
0
][
0
]
=
x
.
copy
()
for
i
in
range
(
2
,
len
(
x
)):
for
i
in
range
(
2
,
len
(
x
)):
y
[
i
]
=
y
[
i
-
1
]
*
y
[
i
-
2
]
+
x
[
i
]
y
[
i
]
=
y
[
i
-
1
]
*
y
[
i
-
2
]
+
x
[
i
]
def
c_code
(
self
,
node
,
name
,
inames
,
onames
,
sub
):
def
c_code
(
self
,
node
,
name
,
inames
,
onames
,
sub
):
x
,
=
inames
x
,
=
inames
...
@@ -1002,35 +1004,35 @@ class T_graphstructures(unittest.TestCase):
...
@@ -1002,35 +1004,35 @@ class T_graphstructures(unittest.TestCase):
from
theano.tensor
import
add
,
mul
,
Apply
,
Variable
,
TensorType
from
theano.tensor
import
add
,
mul
,
Apply
,
Variable
,
TensorType
# Instantiate a type that represents a matrix of doubles
# Instantiate a type that represents a matrix of doubles
float64_matrix
=
TensorType
(
dtype
=
'float64'
,
# double
float64_matrix
=
TensorType
(
dtype
=
'float64'
,
# double
broadcastable
=
(
False
,
False
))
# matrix
broadcastable
=
(
False
,
False
))
# matrix
# We make the Variable instances we need.
# We make the Variable instances we need.
x
=
Variable
(
type
=
float64_matrix
,
name
=
'x'
)
x
=
Variable
(
type
=
float64_matrix
,
name
=
'x'
)
y
=
Variable
(
type
=
float64_matrix
,
name
=
'y'
)
y
=
Variable
(
type
=
float64_matrix
,
name
=
'y'
)
z
=
Variable
(
type
=
float64_matrix
,
name
=
'z'
)
z
=
Variable
(
type
=
float64_matrix
,
name
=
'z'
)
# This is the Variable that we want to symbolically represents y*z
# This is the Variable that we want to symbolically represents y*z
mul_variable
=
Variable
(
type
=
float64_matrix
)
mul_variable
=
Variable
(
type
=
float64_matrix
)
assert
mul_variable
.
owner
is
None
assert
mul_variable
.
owner
is
None
# Instantiate a symbolic multiplication
# Instantiate a symbolic multiplication
node_mul
=
Apply
(
op
=
mul
,
node_mul
=
Apply
(
op
=
mul
,
inputs
=
[
y
,
z
],
inputs
=
[
y
,
z
],
outputs
=
[
mul_variable
])
outputs
=
[
mul_variable
])
# Fields 'owner' and 'index' are set by Apply
# Fields 'owner' and 'index' are set by Apply
assert
mul_variable
.
owner
is
node_mul
assert
mul_variable
.
owner
is
node_mul
# 'index' is the position of mul_variable in mode_mul's outputs
# 'index' is the position of mul_variable in mode_mul's outputs
assert
mul_variable
.
index
==
0
assert
mul_variable
.
index
==
0
# This is the Variable that we want to symbolically represents x+(y*z)
# This is the Variable that we want to symbolically represents x+(y*z)
add_variable
=
Variable
(
type
=
float64_matrix
)
add_variable
=
Variable
(
type
=
float64_matrix
)
assert
add_variable
.
owner
is
None
assert
add_variable
.
owner
is
None
# Instantiate a symbolic addition
# Instantiate a symbolic addition
node_add
=
Apply
(
op
=
add
,
node_add
=
Apply
(
op
=
add
,
inputs
=
[
x
,
mul_variable
],
inputs
=
[
x
,
mul_variable
],
outputs
=
[
add_variable
])
outputs
=
[
add_variable
])
# Fields 'owner' and 'index' are set by Apply
# Fields 'owner' and 'index' are set by Apply
assert
add_variable
.
owner
is
node_add
assert
add_variable
.
owner
is
node_add
assert
add_variable
.
index
==
0
assert
add_variable
.
index
==
0
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论