Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0c5dc59f
提交
0c5dc59f
authored
7月 08, 2011
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
C code for subtensor and inc_subtensor
上级
7e7998ec
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
36 行增加
和
4 行删除
+36
-4
basic.py
theano/tensor/basic.py
+0
-0
test_basic.py
theano/tensor/tests/test_basic.py
+1
-2
test_inc_subtensor.py
theano/tensor/tests/test_inc_subtensor.py
+35
-2
没有找到文件。
theano/tensor/basic.py
浏览文件 @
0c5dc59f
差异被折叠。
点击展开。
theano/tensor/tests/test_basic.py
浏览文件 @
0c5dc59f
...
@@ -2057,7 +2057,7 @@ class T_subtensor(unittest.TestCase):
...
@@ -2057,7 +2057,7 @@ class T_subtensor(unittest.TestCase):
for
stop
in
[
None
]
+
[
-
8
,
-
5
,
-
1
,
0
,
1
,
5
,
8
]:
for
stop
in
[
None
]
+
[
-
8
,
-
5
,
-
1
,
0
,
1
,
5
,
8
]:
for
step
in
[
None
]
+
[
-
3
,
-
1
,
2
]:
for
step
in
[
None
]
+
[
-
3
,
-
1
,
2
]:
outs
+=
[
data
[
start
:
stop
:
step
]
.
shape
]
outs
+=
[
data
[
start
:
stop
:
step
]
.
shape
]
shapes
+=
[
data
.
get_value
()[
start
:
stop
:
step
]
.
shape
]
shapes
+=
[
data
.
get_value
(
borrow
=
True
)[
start
:
stop
:
step
]
.
shape
]
f
=
function
([],
outs
,
mode
=
mode_opt
)
f
=
function
([],
outs
,
mode
=
mode_opt
)
t_shapes
=
f
()
t_shapes
=
f
()
for
t_shape
,
shape
in
zip
(
t_shapes
,
shapes
):
for
t_shape
,
shape
in
zip
(
t_shapes
,
shapes
):
...
@@ -2065,7 +2065,6 @@ class T_subtensor(unittest.TestCase):
...
@@ -2065,7 +2065,6 @@ class T_subtensor(unittest.TestCase):
assert
theano
.
tensor
.
Subtensor
not
in
[
x
.
op
for
x
in
assert
theano
.
tensor
.
Subtensor
not
in
[
x
.
op
for
x
in
f
.
maker
.
env
.
toposort
()
]
f
.
maker
.
env
.
toposort
()
]
def
test_shape_i_scalar
(
self
):
def
test_shape_i_scalar
(
self
):
# Each axis is treated independently by shape_i/shape operators
# Each axis is treated independently by shape_i/shape operators
...
...
theano/tensor/tests/test_inc_subtensor.py
浏览文件 @
0c5dc59f
...
@@ -20,7 +20,7 @@ class Test_inc_subtensor(unittest.TestCase):
...
@@ -20,7 +20,7 @@ class Test_inc_subtensor(unittest.TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
utt
.
seed_rng
()
utt
.
seed_rng
()
def
test_simple_
ok
(
self
):
def
test_simple_
2d
(
self
):
"""Increments or sets part of a tensor by a scalar using full slice and
"""Increments or sets part of a tensor by a scalar using full slice and
a partial slice depending on a scalar.
a partial slice depending on a scalar.
"""
"""
...
@@ -52,8 +52,41 @@ class Test_inc_subtensor(unittest.TestCase):
...
@@ -52,8 +52,41 @@ class Test_inc_subtensor(unittest.TestCase):
expected_result
[:,:
val_sl2_end
]
+=
val_inc
expected_result
[:,:
val_sl2_end
]
+=
val_inc
self
.
assertTrue
(
numpy
.
array_equal
(
result
,
expected_result
))
self
.
assertTrue
(
numpy
.
array_equal
(
result
,
expected_result
))
return
def
test_simple_3d
(
self
):
"""Increments or sets part of a tensor by a scalar using full slice and
a partial slice depending on a scalar.
"""
a
=
T
.
dtensor3
()
increment
=
T
.
dscalar
()
sl1
=
slice
(
None
)
sl2_end
=
T
.
lscalar
()
sl2
=
slice
(
sl2_end
)
sl3
=
2
for
do_set
in
[
True
,
False
]:
print
"Set"
,
do_set
if
do_set
:
resut
=
T
.
set_subtensor
(
a
[
sl1
,
sl3
,
sl2
],
increment
)
else
:
resut
=
T
.
inc_subtensor
(
a
[
sl1
,
sl3
,
sl2
],
increment
)
f
=
theano
.
function
([
a
,
increment
,
sl2_end
],
resut
)
val_a
=
numpy
.
ones
((
5
,
3
,
4
))
val_inc
=
2.3
val_sl2_end
=
2
expected_result
=
numpy
.
copy
(
val_a
)
result
=
f
(
val_a
,
val_inc
,
val_sl2_end
)
if
do_set
:
expected_result
[:,
sl3
,:
val_sl2_end
]
=
val_inc
else
:
expected_result
[:,
sl3
,:
val_sl2_end
]
+=
val_inc
self
.
assertTrue
(
numpy
.
array_equal
(
result
,
expected_result
))
def
test_grad
(
self
):
def
test_grad
(
self
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论