Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
584c0c15
Unverified
提交
584c0c15
authored
2月 18, 2021
作者:
Brandon T. Willard
提交者:
GitHub
2月 18, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge pull request #305 from brandonwillard/fix-split-errors
Fix Split.__str__ and adjust its error messages
上级
bd54469c
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
7 行增加
和
18 行删除
+7
-18
basic.py
aesara/tensor/basic.py
+7
-18
没有找到文件。
aesara/tensor/basic.py
浏览文件 @
584c0c15
...
@@ -1844,7 +1844,7 @@ class Split(COp):
...
@@ -1844,7 +1844,7 @@ class Split(COp):
self
.
len_splits
=
int
(
len_splits
)
self
.
len_splits
=
int
(
len_splits
)
def
__str__
(
self
):
def
__str__
(
self
):
return
"{self.__class__.__name__ }{{{self.len_splits}}}"
return
f
"{self.__class__.__name__ }{{{self.len_splits}}}"
def
make_node
(
self
,
x
,
axis
,
splits
):
def
make_node
(
self
,
x
,
axis
,
splits
):
"""WRITEME"""
"""WRITEME"""
...
@@ -1853,9 +1853,9 @@ class Split(COp):
...
@@ -1853,9 +1853,9 @@ class Split(COp):
splits
=
as_tensor_variable
(
splits
)
splits
=
as_tensor_variable
(
splits
)
if
splits
.
type
not
in
int_vector_types
:
if
splits
.
type
not
in
int_vector_types
:
raise
TypeError
(
"
splits must have type tensor.lvector"
,
splits
.
type
)
raise
TypeError
(
"
`splits` parameter must be tensors of integer type"
)
if
axis
.
type
not
in
int_types
:
if
axis
.
type
not
in
int_types
:
raise
TypeError
(
"
axis must have type lscalar"
,
axis
.
type
)
raise
TypeError
(
"
`axis` parameter must be an integer scalar"
)
# # The following lines are necessary if we allow splits of zero
# # The following lines are necessary if we allow splits of zero
# if isinstance(axis, Constant):
# if isinstance(axis, Constant):
...
@@ -1869,30 +1869,19 @@ class Split(COp):
...
@@ -1869,30 +1869,19 @@ class Split(COp):
return
Apply
(
self
,
inputs
,
outputs
)
return
Apply
(
self
,
inputs
,
outputs
)
def
perform
(
self
,
node
,
inputs
,
outputs
):
def
perform
(
self
,
node
,
inputs
,
outputs
):
"""WRITEME"""
x
,
axis
,
splits
=
inputs
x
,
axis
,
splits
=
inputs
try
:
len_along_axis
=
x
.
shape
[
axis
]
len_along_axis
=
x
.
shape
[
axis
]
except
Exception
:
raise
ValueError
(
f
"Split.perform() with axis=({axis}) is invalid"
f
" for x.shape==({x.shape})"
)
if
len
(
splits
)
!=
self
.
len_splits
:
raise
ValueError
(
"In Split.perform(), len(splits) != len_splits."
,
(
len
(
splits
),
self
.
len_splits
),
)
if
len
(
splits
)
!=
self
.
len_splits
:
raise
ValueError
(
"Length of `splits` is not equal to `len_splits`"
)
if
np
.
sum
(
splits
)
!=
len_along_axis
:
if
np
.
sum
(
splits
)
!=
len_along_axis
:
raise
ValueError
(
raise
ValueError
(
f
"The splits sum to {np.sum(splits)}
,
expected {len_along_axis}"
f
"The splits sum to {np.sum(splits)}
;
expected {len_along_axis}"
)
)
if
builtins
.
any
([
nb
<
0
for
nb
in
splits
]):
if
builtins
.
any
([
nb
<
0
for
nb
in
splits
]):
raise
ValueError
(
raise
ValueError
(
"Split: you tried to make an ndarray with a "
"Attempted to make an array with a "
"negative number of elements"
"negative number of elements."
)
)
# Checking is done, let's roll the splitting algorithm!
# Checking is done, let's roll the splitting algorithm!
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论