Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fac6c2b2
提交
fac6c2b2
authored
11月 25, 2016
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix in advanced_inc_subtensor1 if index is broadcastable
上级
a7900bd8
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
19 行增加
和
1 行删除
+19
-1
subtensor.py
theano/tensor/subtensor.py
+5
-1
test_subtensor.py
theano/tensor/tests/test_subtensor.py
+14
-0
没有找到文件。
theano/tensor/subtensor.py
浏览文件 @
fac6c2b2
...
...
@@ -1157,7 +1157,11 @@ def inc_subtensor(x, y, inplace=False, set_instead_of_inc=False,
inplace
=
inplace
,
set_instead_of_inc
=
set_instead_of_inc
,
tolerate_inplace_aliasing
=
tolerate_inplace_aliasing
)
return
x
.
owner
.
op
(
inner_incsubtensor
,
*
x
.
owner
.
inputs
[
1
:])
# The broadcastable pattern of inner_x may not be the same as
# the one of x, so we have to build a new dimshuffle here,
# instead of reusing x.owner.op().
return
inner_incsubtensor
.
dimshuffle
(
x
.
owner
.
op
.
new_order
)
elif
isinstance
(
x
.
owner
.
op
,
theano
.
tensor
.
Reshape
):
# This case happens when the indices are not arranged as a vector, but
# as a higher-dimensional array. This is handled by the subtensor
...
...
theano/tensor/tests/test_subtensor.py
浏览文件 @
fac6c2b2
...
...
@@ -1325,6 +1325,20 @@ class TestIncSubtensor1(unittest.TestCase):
utt
.
assert_allclose
(
a2val
[
2
],
mval
[
2
]
*
3
)
utt
.
assert_allclose
(
a2val
[
3
],
mval
[
3
]
*
2
)
def
test_inc_bcastableidx
(
self
):
idx
=
tensor
.
constant
([
0
])
c_inc
=
tensor
.
col
()
m_inc
=
tensor
.
matrix
()
out1
=
inc_subtensor
(
self
.
m
[:,
idx
],
c_inc
)
out2
=
inc_subtensor
(
self
.
m
[:,
idx
],
m_inc
)
f
=
theano
.
function
([
self
.
m
,
c_inc
,
m_inc
],
[
out1
,
out2
])
mval
=
self
.
rng
.
random_sample
((
10
,
5
))
incval
=
self
.
rng
.
random_sample
((
10
,
1
))
.
astype
(
config
.
floatX
)
out1val
,
out2val
=
f
(
mval
,
incval
,
incval
)
utt
.
assert_allclose
(
out1val
,
out2val
)
inplace_increment_missing
=
SkipTest
(
"inc_subtensor with advanced indexing not enabled. "
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论