Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
41946da9
提交
41946da9
authored
3月 21, 2011
作者:
Razvan Pascanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refractored the test for shape_i in one that considers constant slices and
one that works on scalars.
上级
64efe269
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
55 行增加
和
4 行删除
+55
-4
test_basic.py
theano/tensor/tests/test_basic.py
+55
-4
没有找到文件。
theano/tensor/tests/test_basic.py
浏览文件 @
41946da9
...
...
@@ -1689,7 +1689,7 @@ class T_subtensor(unittest.TestCase):
self
.
failUnless
(
isinstance
(
topo_
[
0
]
.
op
,
self
.
adv_sub1
))
self
.
assertRaises
(
IndexError
,
f
)
def
test_shape_i
(
self
):
def
test_shape_i
_const
(
self
):
# Each axis is treated independently by shape_i/shape operators
mode_opt
=
config
.
mode
...
...
@@ -1697,11 +1697,11 @@ class T_subtensor(unittest.TestCase):
mode_opt
=
'FAST_RUN'
mode_opt
=
compile
.
mode
.
get_mode
(
mode_opt
)
data
=
self
.
shared
(
numpy
.
zeros
((
5
,
),
dtype
=
'int32'
))
for
start
in
[
None
]
+
[
-
8
,
-
5
,
-
4
,
-
1
,
0
,
1
,
4
,
5
,
8
]:
data
=
self
.
shared
(
numpy
.
array
(
numpy
.
arange
(
5
),
dtype
=
'int32'
))
for
start
in
[
None
]
+
[
-
8
,
-
5
,
-
1
,
0
,
1
,
5
,
8
]:
outs
=
[]
shapes
=
[]
for
stop
in
[
None
]
+
[
-
8
,
-
5
,
-
4
,
-
1
,
0
,
1
,
4
,
5
,
8
]:
for
stop
in
[
None
]
+
[
-
8
,
-
5
,
-
1
,
0
,
1
,
5
,
8
]:
for
step
in
[
None
]
+
[
-
3
,
-
1
,
2
]:
outs
+=
[
data
[
start
:
stop
:
step
]
.
shape
]
shapes
+=
[
data
.
get_value
()[
start
:
stop
:
step
]
.
shape
]
...
...
@@ -1713,6 +1713,57 @@ class T_subtensor(unittest.TestCase):
f
.
maker
.
env
.
toposort
()
]
def
test_shape_i_scalar
(
self
):
# Each axis is treated independently by shape_i/shape operators
mode_opt
=
config
.
mode
if
mode_opt
==
'FAST_COMPILE'
:
mode_opt
=
'FAST_RUN'
mode_opt
=
compile
.
mode
.
get_mode
(
mode_opt
)
v_data
=
numpy
.
array
(
numpy
.
arange
(
5
),
dtype
=
'int32'
)
t_data
=
self
.
shared
(
v_data
)
start
=
theano
.
tensor
.
iscalar
(
'b'
)
stop
=
theano
.
tensor
.
iscalar
(
'e'
)
step
=
theano
.
tensor
.
iscalar
(
's'
)
f
=
function
([
start
,
stop
,
step
],
t_data
[
start
:
stop
:
step
]
.
shape
,
mode
=
mode_opt
)
f2
=
function
([
start
,
stop
,
step
],
t_data
[
start
:
stop
:
step
])
assert
theano
.
tensor
.
Subtensor
not
in
[
x
.
op
for
x
in
f
.
maker
.
env
.
toposort
()
]
for
start
in
[
-
8
,
-
5
,
-
4
,
-
1
,
0
,
1
,
4
,
5
,
8
]:
for
stop
in
[
-
8
,
-
5
,
-
4
,
-
1
,
0
,
1
,
4
,
5
,
8
]:
for
step
in
[
-
3
,
-
1
,
2
,
5
]:
assert
numpy
.
all
(
f
(
start
,
stop
,
step
)
==
v_data
[
start
:
stop
:
step
]
.
shape
)
def
test_slice_canonical_form_0
(
self
):
start
=
theano
.
tensor
.
iscalar
(
'b'
)
stop
=
theano
.
tensor
.
iscalar
(
'e'
)
step
=
theano
.
tensor
.
iscalar
(
's'
)
length
=
theano
.
tensor
.
iscalar
(
'l'
)
cnf
=
theano
.
tensor
.
basic
.
get_canonical_form_slice
(
slice
(
start
,
stop
,
step
),
length
)
f
=
function
([
start
,
stop
,
step
,
length
],
[
theano
.
tensor
.
as_tensor_variable
(
cnf
[
0
]
.
start
),
theano
.
tensor
.
as_tensor_variable
(
cnf
[
0
]
.
stop
),
theano
.
tensor
.
as_tensor_variable
(
cnf
[
0
]
.
step
),
theano
.
tensor
.
as_tensor_variable
(
cnf
[
1
])
])
length
=
5
a
=
numpy
.
arange
(
length
)
for
start
in
[
-
8
,
-
5
,
-
4
,
-
1
,
0
,
1
,
4
,
5
,
8
]:
for
stop
in
[
-
8
,
-
5
,
-
4
,
-
1
,
0
,
1
,
4
,
5
,
8
]:
for
step
in
[
-
6
,
-
3
,
-
1
,
2
,
5
]:
out
=
f
(
start
,
stop
,
step
,
length
)
t_out
=
a
[
out
[
0
]:
out
[
1
]:
out
[
2
]][::
out
[
3
]]
v_out
=
a
[
start
:
stop
:
step
]
assert
numpy
.
all
(
t_out
==
v_out
)
assert
numpy
.
all
(
t_out
.
shape
==
v_out
.
shape
)
def
grad_list_
(
self
,
idxs
,
data
):
n
=
self
.
shared
(
data
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论