Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
63b0d7ea
提交
63b0d7ea
authored
6月 29, 2012
作者:
Nicolas Bouchard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix RepeatOp.grad
上级
f815e119
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
15 行增加
和
17 行删除
+15
-17
extra_ops.py
theano/tensor/extra_ops.py
+15
-17
没有找到文件。
theano/tensor/extra_ops.py
浏览文件 @
63b0d7ea
...
@@ -259,20 +259,18 @@ def squeeze(x, out_nd):
...
@@ -259,20 +259,18 @@ def squeeze(x, out_nd):
class
RepeatOp
(
theano
.
Op
):
class
RepeatOp
(
theano
.
Op
):
"""Repeat elements of an array.
"""Repeat elements of an array.
It returns an array which has the same shape as
x
, except
It returns an array which has the same shape as
`x`
, except
along the given axis. The axis is used to speficy along which
along the given axis. The axis is used to speficy along which
axis to repeat values. By default, use the flattened input
axis to repeat values. By default, use the flattened input
array, and return a flat output array.
array, and return a flat output array.
The number of repetitions for each element is
repeat
.
The number of repetitions for each element is
`repeat`
.
repeats is broadcasted to fit the shape of the given axis
.
`repeats` is broadcasted to fit the length of the given `axis`
.
Parameter:
:param x: Input data, tensor variable.
x -- Input data, tensor variable.
:param repeats: int, scalar or tensor variable.
repeats -- int, tensor variable.
Keywords arguments:
:param axis: int, optional.
axis -- int, optional.
"""
"""
def
__init__
(
self
,
axis
=
None
):
def
__init__
(
self
,
axis
=
None
):
...
@@ -316,6 +314,9 @@ class RepeatOp(theano.Op):
...
@@ -316,6 +314,9 @@ class RepeatOp(theano.Op):
return
[
gz
.
reshape
(
shape
,
x
.
ndim
+
1
)
.
sum
(
axis
=
axis
),
None
]
return
[
gz
.
reshape
(
shape
,
x
.
ndim
+
1
)
.
sum
(
axis
=
axis
),
None
]
elif
repeats
.
ndim
==
1
:
elif
repeats
.
ndim
==
1
:
# For this implementation, we would need to specify the length
# of repeats in order to split gz in the right way to sum
# the good part.
raise
NotImplementedError
()
raise
NotImplementedError
()
else
:
else
:
raise
ValueError
()
raise
ValueError
()
...
@@ -344,21 +345,18 @@ class RepeatOp(theano.Op):
...
@@ -344,21 +345,18 @@ class RepeatOp(theano.Op):
def
repeat
(
x
,
repeats
,
axis
=
None
):
def
repeat
(
x
,
repeats
,
axis
=
None
):
"""Repeat elements of an array.
"""Repeat elements of an array.
It returns an array which has the same shape as
x
, except
It returns an array which has the same shape as
`x`
, except
along the given axis. The axis is used to speficy along which
along the given axis. The axis is used to speficy along which
axis to repeat values. By default, use the flattened input
axis to repeat values. By default, use the flattened input
array, and return a flat output array.
array, and return a flat output array.
The number of repetitions for each element is
repeat
.
The number of repetitions for each element is
`repeat`
.
repeats is broadcasted to fit the shape of the given axis
.
`repeats` is broadcasted to fit the length of the given `axis`
.
Parameter:
:param x: Input data, tensor variable.
x -- Input data, tensor variable.
:param repeats: int, scalar or tensor variable.
repeats -- int, tensor variable.
Keywords arguments:
axis -- int, optional.
:param axis: int, optional.
"""
"""
return
RepeatOp
(
axis
=
axis
)(
x
,
repeats
)
return
RepeatOp
(
axis
=
axis
)(
x
,
repeats
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论