Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
aa278955
提交
aa278955
authored
7月 21, 2009
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test_elemwise1 passes, didnt run in debugmode
上级
56d152c8
全部展开
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
31 行增加
和
5 行删除
+31
-5
__init__.py
__init__.py
+3
-0
basic_ops.py
basic_ops.py
+0
-0
test_basic_ops.py
tests/test_basic_ops.py
+28
-5
没有找到文件。
__init__.py
浏览文件 @
aa278955
...
@@ -4,3 +4,6 @@ from .var import (CudaNdarrayVariable,
...
@@ -4,3 +4,6 @@ from .var import (CudaNdarrayVariable,
CudaNdarrayConstant
,
CudaNdarrayConstant
,
CudaNdarraySharedVariable
,
CudaNdarraySharedVariable
,
shared_constructor
)
shared_constructor
)
import
basic_ops
import
opt
basic_ops.py
浏览文件 @
aa278955
差异被折叠。
点击展开。
tests/test_basic_ops.py
浏览文件 @
aa278955
import
sys
from
theano.compile.sandbox.sharedvalue
import
shared
from
theano.compile.sandbox.sharedvalue
import
shared
from
theano.compile.sandbox.pfunc
import
pfunc
from
theano.compile.sandbox.pfunc
import
pfunc
from
theano
import
tensor
from
theano
import
tensor
...
@@ -11,7 +12,7 @@ def test_elemwise0():
...
@@ -11,7 +12,7 @@ def test_elemwise0():
a
=
tcn
.
shared_constructor
(
numpy
.
random
.
rand
(
4
,
4
),
'a'
)
a
=
tcn
.
shared_constructor
(
numpy
.
random
.
rand
(
4
,
4
),
'a'
)
b
=
tensor
.
d
matrix
()
b
=
tensor
.
f
matrix
()
f
=
pfunc
([
b
],
[],
updates
=
[(
a
,
a
+
b
)])
f
=
pfunc
([
b
],
[],
updates
=
[(
a
,
a
+
b
)])
...
@@ -27,11 +28,27 @@ def test_elemwise1():
...
@@ -27,11 +28,27 @@ def test_elemwise1():
""" Several kinds of elemwise expressions with no broadcasting, non power-of-two shape """
""" Several kinds of elemwise expressions with no broadcasting, non power-of-two shape """
shape
=
(
3
,
4
)
shape
=
(
3
,
4
)
a
=
tcn
.
shared_constructor
(
numpy
.
random
.
rand
(
*
shape
),
'a'
)
a
=
tcn
.
shared_constructor
(
numpy
.
random
.
rand
(
*
shape
)
+
0.5
,
'a'
)
b
=
tensor
.
d
matrix
()
b
=
tensor
.
f
matrix
()
f
=
pfunc
([
b
],
[],
updates
=
[(
a
,
a
+
b
*
tensor
.
exp
(
b
**
a
))])
#let debugmode catch any mistakes
#let debugmode catch any mistakes
f
(
numpy
.
ones
(
shape
))
print
>>
sys
.
stderr
,
"STARTING FUNCTION 1"
f
=
pfunc
([
b
],
[],
updates
=
[(
a
,
b
**
a
)])
for
i
,
node
in
enumerate
(
f
.
maker
.
env
.
toposort
()):
print
i
,
node
f
(
numpy
.
random
.
rand
(
*
shape
)
+
0.3
)
print
>>
sys
.
stderr
,
"STARTING FUNCTION 2"
#let debugmode catch any mistakes
f
=
pfunc
([
b
],
[],
updates
=
[(
a
,
tensor
.
exp
(
b
**
a
))])
for
i
,
node
in
enumerate
(
f
.
maker
.
env
.
toposort
()):
print
i
,
node
f
(
numpy
.
random
.
rand
(
*
shape
)
+
0.3
)
print
>>
sys
.
stderr
,
"STARTING FUNCTION 3"
#let debugmode catch any mistakes
f
=
pfunc
([
b
],
[],
updates
=
[(
a
,
a
+
b
*
tensor
.
exp
(
b
**
a
))])
f
(
numpy
.
random
.
rand
(
*
shape
)
+
0.3
)
def
test_elemwise2
():
def
test_elemwise2
():
""" Several kinds of elemwise expressions with dimension permutations """
""" Several kinds of elemwise expressions with dimension permutations """
...
@@ -41,6 +58,11 @@ def test_elemwise2():
...
@@ -41,6 +58,11 @@ def test_elemwise2():
b
=
tensor
.
Tensor
(
dtype
=
'float32'
,
broadcastable
=
[
0
]
*
len
(
shape
))()
b
=
tensor
.
Tensor
(
dtype
=
'float32'
,
broadcastable
=
[
0
]
*
len
(
shape
))()
f
=
pfunc
([
b
],
[],
updates
=
[(
a
,
(
a
+
b
)
.
dimshuffle
([
2
,
0
,
3
,
1
])
*
f
=
pfunc
([
b
],
[],
updates
=
[(
a
,
(
a
+
b
)
.
dimshuffle
([
2
,
0
,
3
,
1
])
*
tensor
.
exp
(
b
**
a
)
.
dimshuffle
([
2
,
0
,
3
,
1
]))])
tensor
.
exp
(
b
**
a
)
.
dimshuffle
([
2
,
0
,
3
,
1
]))])
has_elemwise
=
False
for
i
,
node
in
enumerate
(
f
.
maker
.
env
.
toposort
()):
print
i
,
node
has_elemwise
=
has_elemwise
or
isinstance
(
node
.
op
,
tensor
.
Elemwise
)
assert
not
has_elemwise
#let debugmode catch errors
#let debugmode catch errors
f
(
numpy
.
ones
(
shape
))
f
(
numpy
.
ones
(
shape
))
...
@@ -54,3 +76,4 @@ def test_elemwise3():
...
@@ -54,3 +76,4 @@ def test_elemwise3():
b
**
a
)
.
dimshuffle
([
2
,
0
,
3
,
1
]))])
b
**
a
)
.
dimshuffle
([
2
,
0
,
3
,
1
]))])
#let debugmode catch errors
#let debugmode catch errors
f
(
numpy
.
ones
(
6
))
f
(
numpy
.
ones
(
6
))
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论