Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
906e1424
提交
906e1424
authored
6月 16, 2024
作者:
Michael Osthege
提交者:
Ricardo Vieira
6月 25, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix type hints here and there
上级
7a00b885
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
12 行增加
和
9 行删除
+12
-9
__init__.py
pytensor/__init__.py
+1
-1
basic.py
pytensor/graph/basic.py
+2
-2
op.py
pytensor/tensor/random/op.py
+2
-1
utils.py
pytensor/tensor/random/utils.py
+3
-1
shape.py
pytensor/tensor/shape.py
+3
-3
type.py
pytensor/tensor/type.py
+1
-1
没有找到文件。
pytensor/__init__.py
浏览文件 @
906e1424
...
...
@@ -108,7 +108,7 @@ def as_symbolic(x: Any, name: str | None = None, **kwargs) -> Variable:
@singledispatch
def
_as_symbolic
(
x
,
**
kwargs
)
->
Variable
:
def
_as_symbolic
(
x
:
Any
,
**
kwargs
)
->
Variable
:
from
pytensor.tensor
import
as_tensor_variable
return
as_tensor_variable
(
x
,
**
kwargs
)
...
...
pytensor/graph/basic.py
浏览文件 @
906e1424
...
...
@@ -1302,8 +1302,8 @@ def clone_node_and_cache(
def
clone_get_equiv
(
inputs
:
Sequenc
e
[
Variable
],
outputs
:
Sequenc
e
[
Variable
],
inputs
:
Iterabl
e
[
Variable
],
outputs
:
Reversibl
e
[
Variable
],
copy_inputs
:
bool
=
True
,
copy_orphans
:
bool
=
True
,
memo
:
dict
[
Union
[
Apply
,
Variable
,
"Op"
],
Union
[
Apply
,
Variable
,
"Op"
]]
...
...
pytensor/tensor/random/op.py
浏览文件 @
906e1424
import
warnings
from
collections.abc
import
Sequence
from
copy
import
copy
from
typing
import
cast
from
typing
import
Any
,
cast
import
numpy
as
np
...
...
@@ -218,6 +218,7 @@ class RandomVariable(Op):
from
pytensor.tensor.extra_ops
import
broadcast_shape_iter
supp_shape
:
tuple
[
Any
]
if
self
.
ndim_supp
==
0
:
supp_shape
=
()
else
:
...
...
pytensor/tensor/random/utils.py
浏览文件 @
906e1424
...
...
@@ -147,7 +147,9 @@ def explicit_expand_dims(
return
new_params
def
compute_batch_shape
(
params
,
ndims_params
:
Sequence
[
int
])
->
TensorVariable
:
def
compute_batch_shape
(
params
:
Sequence
[
TensorVariable
],
ndims_params
:
Sequence
[
int
]
)
->
TensorVariable
:
params
=
explicit_expand_dims
(
params
,
ndims_params
)
batch_params
=
[
param
[(
...
,
*
(
0
,)
*
core_ndim
)]
...
...
pytensor/tensor/shape.py
浏览文件 @
906e1424
...
...
@@ -144,14 +144,14 @@ class Shape(COp):
_shape
=
Shape
()
def
shape
(
x
:
np
.
ndarray
|
Number
|
Variable
)
->
Variable
:
def
shape
(
x
:
np
.
ndarray
|
Number
|
Variable
)
->
Tensor
Variable
:
"""Return the shape of `x`."""
if
not
isinstance
(
x
,
Variable
):
# The following is a type error in Python 3.9 but not 3.12.
# Thus we need to ignore unused-ignore on 3.12.
x
=
ptb
.
as_tensor_variable
(
x
)
# type: ignore[arg-type,unused-ignore]
return
cast
(
Variable
,
_shape
(
x
))
return
cast
(
Tensor
Variable
,
_shape
(
x
))
@_get_vector_length.register
(
Shape
)
# type: ignore
...
...
@@ -195,7 +195,7 @@ def shape_tuple(x: TensorVariable) -> tuple[Variable, ...]:
# TODO: Why not use uint64?
res
+=
(
pytensor
.
scalar
.
ScalarConstant
(
pytensor
.
scalar
.
int64
,
shape_val
),)
else
:
res
+=
(
symbolic_shape
[
i
],)
# type: ignore
res
+=
(
symbolic_shape
[
i
],)
return
res
...
...
pytensor/tensor/type.py
浏览文件 @
906e1424
...
...
@@ -138,7 +138,7 @@ class TensorType(CType[np.ndarray], HasDataType, HasShape):
shape
=
self
.
shape
return
type
(
self
)(
dtype
,
shape
,
name
=
self
.
name
)
def
filter
(
self
,
data
,
strict
=
False
,
allow_downcast
=
None
):
def
filter
(
self
,
data
,
strict
=
False
,
allow_downcast
=
None
)
->
np
.
ndarray
:
"""Convert `data` to something which can be associated to a `TensorVariable`.
This function is not meant to be called in user code. It is for
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论