Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4e107721
提交
4e107721
authored
12月 09, 2021
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
12月 09, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix a RandomVariable DimShuffle lift case for empty sizes
上级
5a2fb70b
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
21 行增加
和
1 行删除
+21
-1
opt.py
aesara/tensor/random/opt.py
+10
-1
test_opt.py
tests/tensor/random/test_opt.py
+11
-0
没有找到文件。
aesara/tensor/random/opt.py
浏览文件 @
4e107721
...
...
@@ -177,9 +177,10 @@ def local_dimshuffle_rv_lift(fgraph, node):
# Update the `size` array to reflect the `DimShuffle`d dimensions,
# since the trailing dimensions in `size` represent the independent
# variates dimensions (for univariate distributions, at least)
has_size
=
get_vector_length
(
size
)
>
0
new_size
=
(
[
constant
(
1
,
dtype
=
"int64"
)
if
o
==
"x"
else
size
[
o
]
for
o
in
ds_new_order
]
if
get_vector_length
(
size
)
>
0
if
has_size
else
size
)
...
...
@@ -190,6 +191,14 @@ def local_dimshuffle_rv_lift(fgraph, node):
d
-
reps_ind_split_idx
if
isinstance
(
d
,
int
)
else
d
for
d
in
ds_new_order
[
ds_ind_new_dims
[
0
][
0
]
:]
]
if
not
has_size
and
len
(
ds_new_order
[:
ds_ind_new_dims
[
0
][
0
]])
>
0
:
# Additional broadcast dimensions need to be added to the
# independent dimensions (i.e. parameters), since there's no
# `size` to which they can be added
rv_params_new_order
=
(
list
(
ds_new_order
[:
ds_ind_new_dims
[
0
][
0
]])
+
rv_params_new_order
)
else
:
# This case is reached when, for example, `ds_new_order` only
# consists of new broadcastable dimensions (i.e. `"x"`s)
...
...
tests/tensor/random/test_opt.py
浏览文件 @
4e107721
...
...
@@ -147,6 +147,17 @@ def test_local_rv_size_lift(dist_op, dist_params, size):
@pytest.mark.parametrize
(
"ds_order, lifted, dist_op, dist_params, size, rtol"
,
[
(
(
"x"
,
0
),
True
,
normal
,
(
np
.
array
([
0.0
,
-
100.0
],
dtype
=
np
.
float64
),
np
.
array
(
1e-6
,
dtype
=
np
.
float64
),
),
(),
1e-7
,
),
(
(
"x"
,),
True
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论