Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
90f300ae
提交
90f300ae
authored
11月 25, 2021
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
12月 05, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix uses of as_tensor_variable in aesara.tensor.subtensor
上级
51de50be
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
18 行增加
和
18 行删除
+18
-18
subtensor.py
aesara/tensor/subtensor.py
+18
-18
没有找到文件。
aesara/tensor/subtensor.py
浏览文件 @
90f300ae
...
...
@@ -18,7 +18,7 @@ from aesara.graph.utils import MethodNotDefined
from
aesara.misc.safe_asarray
import
_asarray
from
aesara.printing
import
Printer
,
pprint
,
set_precedence
from
aesara.scalar.basic
import
ScalarConstant
from
aesara.tensor
import
_get_vector_length
,
get_vector_length
from
aesara.tensor
import
_get_vector_length
,
as_tensor_variable
,
get_vector_length
from
aesara.tensor.basic
import
addbroadcast
,
alloc
,
get_scalar_constant_value
from
aesara.tensor.elemwise
import
DimShuffle
from
aesara.tensor.exceptions
import
(
...
...
@@ -129,7 +129,7 @@ def as_index_constant(
elif
isinstance
(
a
,
(
int
,
np
.
integer
)):
return
aes
.
ScalarConstant
(
aes
.
int64
,
a
)
elif
not
isinstance
(
a
,
Variable
):
return
a
esara
.
tensor
.
as_tensor
(
a
)
return
a
s_tensor_variable
(
a
)
else
:
return
a
...
...
@@ -687,7 +687,7 @@ class Subtensor(COp):
A list of aesara Scalars.
"""
x
=
a
esara
.
tensor
.
a
s_tensor_variable
(
x
)
x
=
as_tensor_variable
(
x
)
inputs
=
tuple
(
as_nontensor_scalar
(
a
)
for
a
in
inputs
)
idx_list
=
list
(
self
.
idx_list
)
...
...
@@ -1291,8 +1291,8 @@ def inc_subtensor(
# First of all, y cannot have a higher dimension than x,
# nor have non-broadcastable dimensions where x is broadcastable.
x
=
a
esara
.
tensor
.
a
s_tensor_variable
(
x
)
y
=
a
esara
.
tensor
.
a
s_tensor_variable
(
y
)
x
=
as_tensor_variable
(
x
)
y
=
as_tensor_variable
(
y
)
if
y
.
ndim
>
x
.
ndim
:
raise
TypeError
(
...
...
@@ -1477,7 +1477,7 @@ class IncSubtensor(COp):
inputs: TODO WRITEME
"""
x
,
y
=
map
(
a
esara
.
tensor
.
a
s_tensor_variable
,
[
x
,
y
])
x
,
y
=
map
(
as_tensor_variable
,
[
x
,
y
])
if
y
.
ndim
>
x
.
ndim
:
raise
ValueError
(
f
"Trying to increment a {int(x.ndim)}-dimensional "
...
...
@@ -1897,8 +1897,8 @@ class AdvancedSubtensor1(COp):
self
.
sparse_grad
=
sparse_grad
def
make_node
(
self
,
x
,
ilist
):
x_
=
a
esara
.
tensor
.
a
s_tensor_variable
(
x
)
ilist_
=
a
esara
.
tensor
.
a
s_tensor_variable
(
ilist
)
x_
=
as_tensor_variable
(
x
)
ilist_
=
as_tensor_variable
(
ilist
)
if
ilist_
.
type
.
dtype
not
in
integer_dtypes
:
raise
TypeError
(
"index must be integers"
)
if
ilist_
.
type
.
ndim
!=
1
:
...
...
@@ -2117,9 +2117,9 @@ class AdvancedIncSubtensor1(COp):
return
self
.
__class__
.
__name__
+
"{
%
s}"
%
msg
def
make_node
(
self
,
x
,
y
,
ilist
):
x_
=
a
esara
.
tensor
.
a
s_tensor_variable
(
x
)
y_
=
a
esara
.
tensor
.
a
s_tensor_variable
(
y
)
ilist_
=
a
esara
.
tensor
.
a
s_tensor_variable
(
ilist
)
x_
=
as_tensor_variable
(
x
)
y_
=
as_tensor_variable
(
y
)
ilist_
=
as_tensor_variable
(
ilist
)
if
ilist_
.
type
.
dtype
not
in
integer_dtypes
:
raise
TypeError
(
"index must be integers"
)
...
...
@@ -2470,7 +2470,7 @@ def as_index_variable(idx):
return
idx
if
isinstance
(
idx
,
Variable
)
and
isinstance
(
idx
.
type
,
NoneTypeT
):
return
idx
idx
=
a
esara
.
tensor
.
a
s_tensor_variable
(
idx
)
idx
=
as_tensor_variable
(
idx
)
if
idx
.
type
.
dtype
not
in
discrete_dtypes
:
raise
TypeError
(
"index must be integers or a boolean mask"
)
return
idx
...
...
@@ -2509,7 +2509,7 @@ class AdvancedSubtensor(Op):
__props__
=
()
def
make_node
(
self
,
x
,
*
index
):
x
=
a
esara
.
tensor
.
a
s_tensor_variable
(
x
)
x
=
as_tensor_variable
(
x
)
index
=
tuple
(
map
(
as_index_variable
,
index
))
# We only want the broadcast information, and we don't need recursive
...
...
@@ -2629,13 +2629,13 @@ class AdvancedIncSubtensor(Op):
)
def
make_node
(
self
,
x
,
y
,
*
inputs
):
x
=
a
esara
.
tensor
.
a
s_tensor_variable
(
x
)
y
=
a
esara
.
tensor
.
a
s_tensor_variable
(
y
)
x
=
as_tensor_variable
(
x
)
y
=
as_tensor_variable
(
y
)
new_inputs
=
[]
for
inp
in
inputs
:
if
isinstance
(
inp
,
(
list
,
tuple
)):
inp
=
a
esara
.
tensor
.
a
s_tensor_variable
(
inp
)
inp
=
as_tensor_variable
(
inp
)
new_inputs
.
append
(
inp
)
return
Apply
(
self
,
...
...
@@ -2726,8 +2726,8 @@ def take(a, indices, axis=None, mode="raise"):
input array is used.
"""
a
=
a
esara
.
tensor
.
a
s_tensor_variable
(
a
)
indices
=
a
esara
.
tensor
.
a
s_tensor_variable
(
indices
)
a
=
as_tensor_variable
(
a
)
indices
=
as_tensor_variable
(
indices
)
if
not
isinstance
(
axis
,
(
int
,
type
(
None
))):
raise
TypeError
(
"`axis` must be an integer or None"
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论