Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
43d58c19
提交
43d58c19
authored
8月 28, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Delete the old unmaintained copy of scan in sandbox.
上级
1d13344e
全部展开
显示空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
0 行增加
和
127 行删除
+0
-127
scan.py
theano/sandbox/scan.py
+0
-0
__init__.py
theano/sandbox/scan_module/__init__.py
+0
-42
scan.py
theano/sandbox/scan_module/scan.py
+0
-0
scan_op.py
theano/sandbox/scan_module/scan_op.py
+0
-0
scan_utils.py
theano/sandbox/scan_module/scan_utils.py
+0
-0
__init__.py
theano/sandbox/scan_module/tests/__init__.py
+0
-0
test_scan.py
theano/sandbox/scan_module/tests/test_scan.py
+0
-0
test_utils.py
theano/sandbox/scan_module/tests/test_utils.py
+0
-0
test_scan.py
theano/sandbox/tests/test_scan.py
+0
-85
没有找到文件。
theano/sandbox/scan.py
deleted
100644 → 0
浏览文件 @
1d13344e
差异被折叠。
点击展开。
theano/sandbox/scan_module/__init__.py
deleted
100644 → 0
浏览文件 @
1d13344e
"""
This module provides the Scan Op.
Scanning is a general form of recurrence, which can be used for looping.
The idea is that you *scan* a function along some input sequence, producing
an output at each time-step that can be seen (but not modified) by the
function at the next time-step. Technically, the function can see the
previous K time-steps of your outputs and L time steps (from the past and
future) of your inputs.
So for example, ``sum()`` could be computed by scanning the ``z+x_i``
function over a list, given an initial state of ``z=0``.
Special cases:
* A *reduce* operation can be performed by returning only the last
output of a ``scan``.
* A *map* operation can be performed by applying a function that
ignores previous steps of the outputs.
Often a for-loop can be expressed as a ``scan()`` operation, and ``scan`` is
the closest that theano comes to looping. The advantage of using ``scan``
over for loops is that it allows the number of iterations to be a part of
the symbolic graph.
The Scan Op should typically be used by calling any of the following
functions: ``scan()``, ``map()``, ``reduce()``, ``foldl()``,
``foldr()``.
"""
__docformat__
=
'restructedtext en'
__authors__
=
(
"Razvan Pascanu "
"Frederic Bastien "
"James Bergstra "
"Pascal Lamblin "
"Arnaud Bergeron "
)
__copyright__
=
"(c) 2010, Universite de Montreal"
__contact__
=
"Razvan Pascanu <r.pascanu@gmail>"
from
.scan
import
scan
theano/sandbox/scan_module/scan.py
deleted
100644 → 0
浏览文件 @
1d13344e
差异被折叠。
点击展开。
theano/sandbox/scan_module/scan_op.py
deleted
100644 → 0
浏览文件 @
1d13344e
差异被折叠。
点击展开。
theano/sandbox/scan_module/scan_utils.py
deleted
100644 → 0
浏览文件 @
1d13344e
差异被折叠。
点击展开。
theano/sandbox/scan_module/tests/__init__.py
deleted
100644 → 0
浏览文件 @
1d13344e
theano/sandbox/scan_module/tests/test_scan.py
deleted
100644 → 0
浏览文件 @
1d13344e
差异被折叠。
点击展开。
theano/sandbox/scan_module/tests/test_utils.py
deleted
100644 → 0
浏览文件 @
1d13344e
差异被折叠。
点击展开。
theano/sandbox/tests/test_scan.py
deleted
100644 → 0
浏览文件 @
1d13344e
import
theano
import
numpy
from
theano.sandbox
import
scan
def
test_001
():
x0
=
theano
.
tensor
.
fvector
(
'x0'
)
state
=
theano
.
tensor
.
unbroadcast
(
theano
.
tensor
.
shape_padleft
(
x0
),
0
)
out
,
_
=
scan
.
scan
(
lambda
x
:
x
+
numpy
.
float32
(
1
),
states
=
state
,
n_steps
=
5
)
fn
=
theano
.
function
([
x0
],
out
[
0
])
val_x0
=
numpy
.
float32
([
1
,
2
,
3
])
assert
numpy
.
all
(
fn
(
val_x0
)
==
val_x0
+
5
)
def
test_002
():
x0
=
theano
.
tensor
.
fvector
(
'x0'
)
state
=
theano
.
tensor
.
alloc
(
theano
.
tensor
.
constant
(
numpy
.
float32
(
0
)),
6
,
x0
.
shape
[
0
])
state
=
theano
.
tensor
.
set_subtensor
(
state
[
0
],
x0
)
out
,
_
=
scan
.
scan
(
lambda
x
:
x
+
numpy
.
float32
(
1
),
states
=
state
,
n_steps
=
5
)
fn
=
theano
.
function
([
x0
],
out
)
val_x0
=
numpy
.
float32
([
1
,
2
,
3
])
assert
numpy
.
all
(
fn
(
val_x0
)[
-
1
]
==
val_x0
+
5
)
assert
numpy
.
all
(
fn
(
val_x0
)[
0
]
==
val_x0
)
def
test_003
():
x0
=
theano
.
tensor
.
fvector
(
'x0'
)
sq
=
theano
.
tensor
.
fvector
(
'sq'
)
state
=
theano
.
tensor
.
alloc
(
theano
.
tensor
.
constant
(
numpy
.
float32
(
0
)),
6
,
x0
.
shape
[
0
])
state
=
theano
.
tensor
.
set_subtensor
(
state
[
0
],
x0
)
out
,
_
=
scan
.
scan
(
lambda
s
,
x
:
x
+
s
,
sequences
=
sq
,
states
=
state
,
n_steps
=
5
)
fn
=
theano
.
function
([
sq
,
x0
],
out
)
val_x0
=
numpy
.
float32
([
1
,
2
,
3
])
val_sq
=
numpy
.
float32
([
1
,
2
,
3
,
4
,
5
])
assert
numpy
.
all
(
fn
(
val_sq
,
val_x0
)[
-
1
]
==
val_x0
+
15
)
assert
numpy
.
all
(
fn
(
val_sq
,
val_x0
)[
0
]
==
val_x0
)
def
test_004
():
sq
=
theano
.
tensor
.
fvector
(
'sq'
)
nst
=
theano
.
tensor
.
iscalar
(
'nst'
)
out
,
_
=
scan
.
scan
(
lambda
s
:
s
+
numpy
.
float32
(
1
),
sequences
=
sq
,
states
=
[],
n_steps
=
nst
)
fn
=
theano
.
function
([
sq
,
nst
],
out
)
val_sq
=
numpy
.
float32
([
1
,
2
,
3
,
4
,
5
])
assert
numpy
.
all
(
fn
(
val_sq
,
5
)
==
val_sq
+
1
)
def
test_005
():
sq
=
theano
.
tensor
.
fvector
(
'sq'
)
nst
=
theano
.
tensor
.
iscalar
(
'nst'
)
out
,
_
=
scan
.
scan
(
lambda
s
:
s
+
numpy
.
float32
(
1
),
sequences
=
sq
,
states
=
[
None
],
n_steps
=
nst
)
fn
=
theano
.
function
([
sq
,
nst
],
out
)
val_sq
=
numpy
.
float32
([
1
,
2
,
3
,
4
,
5
])
assert
numpy
.
all
(
fn
(
val_sq
,
5
)
==
val_sq
+
1
)
if
__name__
==
'__main__'
:
test_001
()
test_002
()
test_003
()
test_004
()
test_005
()
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论