Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
84e69fc8
提交
84e69fc8
authored
9月 16, 2022
作者:
Ricardo Vieira
提交者:
Brandon T. Willard
9月 19, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow TensorType convert_variable to work with mixed static shapes
上级
7d0edb87
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
17 行增加
和
8 行删除
+17
-8
type.py
aesara/tensor/type.py
+5
-8
test_type.py
tests/tensor/test_type.py
+12
-0
没有找到文件。
aesara/tensor/type.py
浏览文件 @
84e69fc8
...
...
@@ -322,16 +322,13 @@ class TensorType(CType[np.ndarray], HasDataType, HasShape):
def
convert_variable
(
self
,
var
):
if
self
.
is_super
(
var
.
type
):
# `var.type` is at least as specific as `self`, so we return
# `var` as-is
# `var.type` is as specific as `self`, so we return `var` as-is
return
var
elif
var
.
type
.
is_super
(
self
):
# `var.type` is less specific than `self`, so we convert
# `var` to `self`'s `Type`.
# Note that, in this case, `var.type != self`, because that's
# covered by the branch above.
# Use the more specific static shape information of the two
if
(
self
.
ndim
==
var
.
type
.
ndim
)
and
(
self
.
dtype
==
var
.
type
.
dtype
):
# `var.type` only differs from `self` in that its shape is (at least partially)
# less specific than `self`, so we convert `var` to `self`'s `Type`.
# `specify_shape` will combine the more precise shapes of the two types
return
aesara
.
tensor
.
specify_shape
(
var
,
self
.
shape
)
def
value_zeros
(
self
,
shape
):
...
...
tests/tensor/test_type.py
浏览文件 @
84e69fc8
...
...
@@ -71,6 +71,18 @@ def test_convert_variable():
assert
res
is
const_var
def
test_convert_variable_mixed_specificity
():
type1
=
TensorType
(
config
.
floatX
,
shape
=
(
1
,
None
,
3
))
type2
=
TensorType
(
config
.
floatX
,
shape
=
(
None
,
5
,
3
))
type3
=
TensorType
(
config
.
floatX
,
shape
=
(
1
,
5
,
3
))
test_var1
=
type1
()
test_var2
=
type2
()
assert
type1
.
convert_variable
(
test_var2
)
.
type
==
type3
assert
type2
.
convert_variable
(
test_var1
)
.
type
==
type3
def
test_filter_variable
():
test_type
=
TensorType
(
config
.
floatX
,
[])
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论