Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3965d55a
提交
3965d55a
authored
11月 21, 2016
作者:
Cesar Laurent
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed n_steps and added testing.
上级
56ab770a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
10 行增加
和
11 行删除
+10
-11
scan_checkpoints.py
theano/scan_module/scan_checkpoints.py
+8
-9
test_scan_checkpoints.py
theano/scan_module/tests/test_scan_checkpoints.py
+2
-2
没有找到文件。
theano/scan_module/scan_checkpoints.py
浏览文件 @
3965d55a
...
...
@@ -53,13 +53,10 @@ def scan_checkpoints(fn, sequences=[], outputs_info=None, non_sequences=[],
n_steps
``n_steps`` is the number of steps to iterate given as an int
or Theano scalar. If any of the input sequences do not have
enough elements, scan will raise an error. If the **value is 0**
the outputs will have **0 rows**. If the value is negative,
``scan`` will run backwards in time. If the ``go_backwards`` flag
is already set and also ``n_steps`` is negative, ``scan`` will run
forward in time. If n_steps is not provided, ``scan`` will figure
out the amount of steps it should run given its input sequences.
or Theano scalar (> 0). If any of the input sequences do not have
enough elements, scan will raise an error. If n_steps is not provided,
``scan`` will figure out the amount of steps it should run given its
input sequences.
save_every_N
``save_every_N`` is the number of steps to go without storing
...
...
@@ -108,8 +105,10 @@ def scan_checkpoints(fn, sequences=[], outputs_info=None, non_sequences=[],
o_n_steps
=
theano
.
tensor
.
cast
(
theano
.
tensor
.
ceil
(
n_steps
/
save_every_N
),
'int64'
)
i_n_steps
=
save_every_N
*
theano
.
tensor
.
ones
((
o_n_steps
,),
'int64'
)
i_n_steps
=
theano
.
tensor
.
inc_subtensor
(
i_n_steps
[
-
1
],
-
n_steps
%
save_every_N
)
mod
=
n_steps
%
save_every_N
sign
=
theano
.
tensor
.
sgn
(
mod
)
rest
=
(
1
-
sign
)
*
save_every_N
+
sign
*
mod
i_n_steps
=
theano
.
tensor
.
set_subtensor
(
i_n_steps
[
-
1
],
rest
)
# Pad the sequences if needed
if
not
no_padding
:
...
...
theano/scan_module/tests/test_scan_checkpoints.py
浏览文件 @
3965d55a
...
...
@@ -38,14 +38,14 @@ class TestScanCheckpoint(unittest.TestCase):
"""Test forward computation of A**k."""
f
=
theano
.
function
(
inputs
=
[
self
.
A
,
self
.
k
],
outputs
=
[
self
.
result
,
self
.
result_check
])
out
,
out_check
=
f
(
range
(
10
),
10
0
)
out
,
out_check
=
f
(
range
(
10
),
10
1
)
assert
numpy
.
allclose
(
out
,
out_check
)
def
test_backward_pass
(
self
):
"""Test gradient computation of A**k."""
f
=
theano
.
function
(
inputs
=
[
self
.
A
,
self
.
k
],
outputs
=
[
self
.
grad_A
,
self
.
grad_A_check
])
out
,
out_check
=
f
(
range
(
10
),
10
0
)
out
,
out_check
=
f
(
range
(
10
),
10
1
)
assert
numpy
.
allclose
(
out
,
out_check
)
@unittest.skipUnless
(
PYGPU_AVAILABLE
,
'Requires pygpu.'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论