Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ae53db81
提交
ae53db81
authored
8月 18, 2015
作者:
Mohammad Pezeshki
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
numerical tests added
上级
6aa9d88e
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
73 行增加
和
1 行删除
+73
-1
test_opt.py
theano/tensor/tests/test_opt.py
+73
-1
没有找到文件。
theano/tensor/tests/test_opt.py
浏览文件 @
ae53db81
...
@@ -59,6 +59,7 @@ from theano.tensor import (
...
@@ -59,6 +59,7 @@ from theano.tensor import (
from
theano.tensor.elemwise
import
DimShuffle
from
theano.tensor.elemwise
import
DimShuffle
from
theano.tests
import
unittest_tools
as
utt
from
theano.tests
import
unittest_tools
as
utt
from
theano.compile.mode
import
optdb
from
theano.compile.mode
import
optdb
from
theano.compile
import
Mode
mode_opt
=
theano
.
config
.
mode
mode_opt
=
theano
.
config
.
mode
if
mode_opt
==
'FAST_COMPILE'
:
if
mode_opt
==
'FAST_COMPILE'
:
...
@@ -4919,7 +4920,7 @@ class T_local_reduce(unittest.TestCase):
...
@@ -4919,7 +4920,7 @@ class T_local_reduce(unittest.TestCase):
theano
.
config
.
warn
.
reduce_join
=
old
theano
.
config
.
warn
.
reduce_join
=
old
class
T_local_sum_dimshuffle
(
unittest
.
TestCase
):
class
T_local_sum_
prod_
dimshuffle
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
mode
=
theano
.
compile
.
get_default_mode
()
.
including
(
'canonicalize'
)
self
.
mode
=
theano
.
compile
.
get_default_mode
()
.
including
(
'canonicalize'
)
...
@@ -4987,6 +4988,77 @@ class T_local_sum_dimshuffle(unittest.TestCase):
...
@@ -4987,6 +4988,77 @@ class T_local_sum_dimshuffle(unittest.TestCase):
config
.
warn
.
sum_sum_bug
,
config
.
warn
.
sum_div_dimshuffle_bug
=
\
config
.
warn
.
sum_sum_bug
,
config
.
warn
.
sum_div_dimshuffle_bug
=
\
backup
backup
def
test_local_prod_div_dimshuffle
(
self
):
a
=
T
.
matrix
(
'a'
)
b
=
T
.
vector
(
'b'
)
c
=
T
.
tensor3
(
'c'
)
d
=
T
.
scalar
(
'd'
)
prod
=
T
.
prod
prods
=
[
prod
(
a
/
d
),
prod
(
a
/
d
.
dimshuffle
(
'x'
,
'x'
)),
prod
(
a
/
d
.
dimshuffle
(
'x'
,
'x'
),
axis
=
0
),
prod
(
a
/
d
.
dimshuffle
(
'x'
,
'x'
),
axis
=
1
),
prod
(
b
/
d
),
prod
(
b
/
d
.
dimshuffle
(
'x'
)),
prod
(
c
/
d
),
prod
(
c
/
d
.
dimshuffle
(
'x'
,
'x'
,
'x'
)),
prod
(
c
/
d
.
dimshuffle
(
'x'
,
'x'
,
'x'
),
axis
=
0
),
prod
(
c
/
d
.
dimshuffle
(
'x'
,
'x'
,
'x'
),
axis
=
1
),
prod
(
c
/
d
.
dimshuffle
(
'x'
,
'x'
,
'x'
),
axis
=
2
),
prod
(
a
/
b
,
axis
=
0
),
prod
(
a
/
b
.
dimshuffle
(
0
,
'x'
),
axis
=
1
),
prod
(
a
.
dimshuffle
(
0
,
1
)
/
b
.
dimshuffle
(
0
,
'x'
),
axis
=
1
),
prod
(
a
.
dimshuffle
(
1
,
0
)
/
b
.
dimshuffle
(
0
,
'x'
),
axis
=
1
),
prod
(
c
/
a
,
axis
=
0
),
prod
(
c
/
a
.
dimshuffle
(
1
,
0
),
axis
=
0
),
prod
(
c
/
a
.
dimshuffle
(
0
,
'x'
,
1
),
axis
=
1
),
prod
(
c
/
a
.
dimshuffle
(
1
,
'x'
,
0
),
axis
=
1
),
prod
(
c
/
a
.
dimshuffle
(
0
,
1
,
'x'
),
axis
=
2
),
prod
(
c
/
a
.
dimshuffle
(
1
,
0
,
'x'
),
axis
=
2
),
prod
(
c
/
b
,
axis
=
0
),
prod
(
c
/
b
,
axis
=
1
),
prod
(
c
/
b
,
axis
=
(
0
,
1
)),
prod
(
c
/
b
.
dimshuffle
(
0
,
'x'
),
axis
=
0
),
prod
(
c
/
b
.
dimshuffle
(
0
,
'x'
),
axis
=
2
),
prod
(
c
/
b
.
dimshuffle
(
0
,
'x'
),
axis
=
(
0
,
2
)),
prod
(
c
/
b
.
dimshuffle
(
0
,
'x'
,
'x'
),
axis
=
1
),
prod
(
c
/
b
.
dimshuffle
(
0
,
'x'
,
'x'
),
axis
=
2
),
prod
(
c
/
b
.
dimshuffle
(
0
,
'x'
,
'x'
),
axis
=
(
1
,
2
)),
prod
(
c
/
b
.
dimshuffle
(
0
,
'x'
,
'x'
),
axis
=
(
0
,
1
)),
prod
(
c
/
b
.
dimshuffle
(
0
,
'x'
,
'x'
),
axis
=
(
1
,
0
)),
prod
(
prod
(
c
,
axis
=
0
)
/
b
,
axis
=
0
),
prod
(
prod
(
c
,
axis
=
1
)
/
b
,
axis
=
0
)]
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
a_val
=
rng
.
randn
(
2
,
2
)
.
astype
(
config
.
floatX
)
b_val
=
rng
.
randn
(
2
)
.
astype
(
config
.
floatX
)
c_val
=
rng
.
randn
(
2
,
2
,
2
)
.
astype
(
config
.
floatX
)
d_val
=
numpy
.
asarray
(
rng
.
randn
(),
config
.
floatX
)
mode_with_opt
=
copy
.
copy
(
theano
.
compile
.
mode
.
get_default_mode
())
mode_without_opt
=
copy
.
copy
(
theano
.
compile
.
mode
.
get_default_mode
())
mode_with_opt
.
_optimizer
=
mode_with_opt
.
_optimizer
.
including
(
'local_sum_prod_div_dimshuffle'
)
mode_without_opt
.
_optimizer
=
mode_without_opt
.
_optimizer
.
excluding
(
'local_sum_prod_div_dimshuffle'
)
for
i
,
s
in
enumerate
(
prods
):
f
=
theano
.
function
([
a
,
b
,
c
,
d
],
s
,
on_unused_input
=
'ignore'
,
mode
=
mode_without_opt
)
g
=
theano
.
function
([
a
,
b
,
c
,
d
],
s
,
on_unused_input
=
'ignore'
,
mode
=
mode_with_opt
)
# g = f.maker.fgraph.toposort()
# assert isinstance(g[-1].op.scalar_op,
# theano.scalar.basic.TrueDiv)
utt
.
assert_allclose
(
f
(
a_val
,
b_val
,
c_val
,
d_val
),
g
(
a_val
,
b_val
,
c_val
,
d_val
))
# TODO:
# TODO:
# test_local_sum_prod_dimshuffle (a * b * c)
# test_local_sum_prod_dimshuffle (a * b * c)
# test_local_sum_divprod_dimshuffle ((a * b) / (c * d))
# test_local_sum_divprod_dimshuffle ((a * b) / (c * d))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论