Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0786f2af
提交
0786f2af
authored
3月 09, 2009
作者:
james@X40
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added doc to Join, and fixed the mixed-input-type bug.
上级
39916a7e
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
12 行删除
+14
-12
basic.py
theano/tensor/basic.py
+14
-12
没有找到文件。
theano/tensor/basic.py
浏览文件 @
0786f2af
...
...
@@ -1574,21 +1574,25 @@ class Join(Op):
def
make_node
(
self
,
*
axis_and_tensors
):
"""
WRITEME
:param axis: an Int or integer-valued Result
:param tensors: a variable number (but not zero) of tensors to concatenate along the
specified axis. These tensors must have the same shape along all dimensions other than this axis.
:returns: a symbolic Result. It has the same ndim as the input tensors, and the most
inclusive dtype.
"""
axis
,
tensors
=
axis_and_tensors
[
0
],
axis_and_tensors
[
1
:]
if
not
tensors
:
raise
ValueError
(
'Cannot join an empty list of tensors'
)
as_tensor_args
=
[
as_tensor
(
x
)
for
x
in
tensors
]
dtypes
=
[
x
.
type
.
dtype
for
x
in
as_tensor_args
]
out_dtype
=
scal
.
upcast
(
*
dtypes
)
if
not
all
(
targs
.
type
.
ndim
for
targs
in
as_tensor_args
):
raise
TypeError
(
'Join cannot handle arguments of dimension 0. For joining scalar values, see @stack'
);
if
not
all
([
dtypes
[
0
]
==
dt
for
dt
in
dtypes
[
1
:]]):
# Note that we could automatically find out the appropriate dtype
# able to store the concatenation of all tensors, but for now we
# just raise an error.
raise
TypeError
(
'All dtypes must match'
,
tensors
)
# When the axis may vary, no dimension can be guaranteed to be
# broadcastable.
bcastable
=
[
False
]
*
len
(
as_tensor_args
[
0
]
.
type
.
broadcastable
)
...
...
@@ -1613,16 +1617,14 @@ class Join(Op):
if
inputs
[
0
]
.
type
not
in
int_types
:
raise
TypeError
(
'Axis could not be cast to an integer type'
,
axis
,
inputs
[
0
]
.
type
,
int_types
)
outputs
=
[
tensor
(
dtype
=
dtypes
[
0
]
,
outputs
=
[
tensor
(
dtype
=
out_dtype
,
broadcastable
=
bcastable
)]
return
Apply
(
self
,
inputs
,
outputs
)
def
perform
(
self
,
node
,
axis_and_tensors
,
(
out
,
)):
"""
WRITEME
"""
axis
,
tensors
=
axis_and_tensors
[
0
],
axis_and_tensors
[
1
:]
out
[
0
]
=
numpy
.
concatenate
(
tensors
,
axis
=
axis
)
out
[
0
]
=
numpy
.
asarray
(
numpy
.
concatenate
(
tensors
,
axis
=
axis
),
dtype
=
node
.
outputs
[
0
]
.
type
.
dtype
)
def
grad
(
self
,
axis_and_tensors
,
(
gz
,)):
""" The gradient wrt a join op is a `Split`, used to partition the gradient along the
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论