Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
80f150b2
提交
80f150b2
authored
10月 28, 2011
作者:
Razvan Pascanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix a bug of grad reported by Michael Forbes
The bug is that we do not clip the sequences to n_steps, meaning that when we revert them for computing the gradient we mess up the gradient.
上级
5dd4c64a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
22 行增加
和
0 行删除
+22
-0
scan.py
theano/scan_module/scan.py
+1
-0
test_scan.py
theano/scan_module/tests/test_scan.py
+21
-0
没有找到文件。
theano/scan_module/scan.py
浏览文件 @
80f150b2
...
...
@@ -538,6 +538,7 @@ def scan( fn
if
getattr
(
seq
[
'input'
],
'name'
,
None
)
is
not
None
:
nw_seq
.
name
=
seq
[
'input'
]
.
name
+
'[
%
d:]'
%
k
scan_seqs
=
[
seq
[:
actual_n_steps
]
for
seq
in
scan_seqs
]
# Conventions :
# mit_mot = multiple input taps, multiple output taps ( only provided
# by the gradient function )
...
...
theano/scan_module/tests/test_scan.py
浏览文件 @
80f150b2
...
...
@@ -2481,6 +2481,27 @@ class T_Scan(unittest.TestCase):
if
isinstance
(
x
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
)]
assert
len
(
lssc
)
==
1
def
test_grad_multiple_seqs_different_nsteps
(
self
):
# Example provided Michael Forbes
# This test assures that we clip the sequences to n_steps before
# computing the gradient (so that when we reverse them we actually
# get the right values in
c
=
theano
.
tensor
.
vector
(
'c'
)
x
=
theano
.
tensor
.
scalar
(
'x'
)
_max_coefficients_supported
=
100
full_range
=
theano
.
tensor
.
arange
(
_max_coefficients_supported
)
components
,
updates
=
theano
.
scan
(
fn
=
lambda
coeff
,
power
,
free_var
:
coeff
*
(
free_var
**
power
),
outputs_info
=
None
,
sequences
=
[
c
,
full_range
],
non_sequences
=
x
)
P
=
components
.
sum
()
dP
=
theano
.
tensor
.
grad
(
P
,
x
)
tf
=
theano
.
function
([
c
,
x
],
dP
)
assert
tf
([
1.0
,
2.0
,
-
3.0
,
4.0
],
2.0
)
==
38
def
test_return_steps
(
self
):
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
vW_in2
=
asarrayX
(
rng
.
uniform
(
size
=
(
2
,),
low
=
-
5.
,
high
=
5.
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论