Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f191a07e
提交
f191a07e
authored
7月 11, 2021
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
7月 11, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add shape_tuple helper function
上级
0cf56c68
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
17 行增加
和
2 行删除
+17
-2
basic.py
aesara/tensor/basic.py
+2
-1
op.py
aesara/tensor/random/op.py
+2
-1
shape.py
aesara/tensor/shape.py
+13
-0
没有找到文件。
aesara/tensor/basic.py
浏览文件 @
f191a07e
...
@@ -42,6 +42,7 @@ from aesara.tensor.shape import (
...
@@ -42,6 +42,7 @@ from aesara.tensor.shape import (
shape_padaxis
,
shape_padaxis
,
shape_padleft
,
shape_padleft
,
shape_padright
,
shape_padright
,
shape_tuple
,
)
)
from
aesara.tensor.type
import
(
from
aesara.tensor.type
import
(
TensorType
,
TensorType
,
...
@@ -4152,7 +4153,7 @@ class Choose(Op):
...
@@ -4152,7 +4153,7 @@ class Choose(Op):
else
:
else
:
choice
=
as_tensor_variable
(
choices
)
choice
=
as_tensor_variable
(
choices
)
(
out_shape
,)
=
self
.
infer_shape
(
(
out_shape
,)
=
self
.
infer_shape
(
None
,
None
,
[
tuple
(
a
.
shape
),
tuple
(
shape
(
choice
)
)]
None
,
None
,
[
shape_tuple
(
a
),
shape_tuple
(
choice
)]
)
)
bcast
=
[]
bcast
=
[]
...
...
aesara/tensor/random/op.py
浏览文件 @
f191a07e
...
@@ -20,6 +20,7 @@ from aesara.tensor.elemwise import Elemwise
...
@@ -20,6 +20,7 @@ from aesara.tensor.elemwise import Elemwise
from
aesara.tensor.exceptions
import
NotScalarConstantError
from
aesara.tensor.exceptions
import
NotScalarConstantError
from
aesara.tensor.random.type
import
RandomType
from
aesara.tensor.random.type
import
RandomType
from
aesara.tensor.random.utils
import
normalize_size_param
,
params_broadcast_shapes
from
aesara.tensor.random.utils
import
normalize_size_param
,
params_broadcast_shapes
from
aesara.tensor.shape
import
shape_tuple
from
aesara.tensor.type
import
TensorType
,
all_dtypes
from
aesara.tensor.type
import
TensorType
,
all_dtypes
...
@@ -199,7 +200,7 @@ class RandomVariable(Op):
...
@@ -199,7 +200,7 @@ class RandomVariable(Op):
# Broadcast the parameters
# Broadcast the parameters
param_shapes
=
params_broadcast_shapes
(
param_shapes
=
params_broadcast_shapes
(
param_shapes
or
[
p
.
shape
for
p
in
dist_params
],
self
.
ndims_params
param_shapes
or
[
shape_tuple
(
p
)
for
p
in
dist_params
],
self
.
ndims_params
)
)
def
slice_ind_dims
(
p
,
ps
,
n
):
def
slice_ind_dims
(
p
,
ps
,
n
):
...
...
aesara/tensor/shape.py
浏览文件 @
f191a07e
...
@@ -129,6 +129,19 @@ shape = Shape()
...
@@ -129,6 +129,19 @@ shape = Shape()
_shape
=
shape
# was used in the past, now use shape directly.
_shape
=
shape
# was used in the past, now use shape directly.
def
shape_tuple
(
x
):
"""Get a tuple of symbolic shape values.
This will return a `ScalarConstant` with the value ``1`` wherever
broadcastable is ``True``.
"""
one_at
=
aesara
.
scalar
.
ScalarConstant
(
aesara
.
scalar
.
int64
,
1
)
return
tuple
(
one_at
if
getattr
(
sh
,
"value"
,
sh
)
==
1
or
bcast
else
sh
for
sh
,
bcast
in
zip
(
shape
(
x
),
getattr
(
x
,
"broadcastable"
,
(
False
,)
*
x
.
ndim
))
)
class
Shape_i
(
COp
):
class
Shape_i
(
COp
):
"""
"""
L{Op} to return the shape of a matrix.
L{Op} to return the shape of a matrix.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论