Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a996911a
提交
a996911a
authored
2月 12, 2010
作者:
Razvan Pascanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bug fixed scan
上级
c710fb2d
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
17 行增加
和
7 行删除
+17
-7
scan.py
theano/scan.py
+17
-7
没有找到文件。
theano/scan.py
浏览文件 @
a996911a
...
@@ -211,15 +211,21 @@ def scan(fn, sequences, initial_states, non_sequences, inplace_map={}, \
...
@@ -211,15 +211,21 @@ def scan(fn, sequences, initial_states, non_sequences, inplace_map={}, \
args
+=
[
init_out
.
type
()
]
args
+=
[
init_out
.
type
()
]
else
:
else
:
args
+=
[
init_out
[
0
]
.
type
()
]
args
+=
[
init_out
[
0
]
.
type
()
]
for
non_seq
in
non_seqs
:
if
not
isinstance
(
non_seq
,
theano
.
compile
.
sharedvalue
.
SharedVariable
):
args
+=
[
non_seq
]
else
:
tmp_var
=
theano
.
tensor
.
Tensor
(
dtype
=
non_seq
.
dtype
,
broadcastable
=
non_seq
.
broadcastable
)()
args
+=
[
tmp_var
]
args
+=
non_seqs
next_outs
=
fn
(
*
args
)
next_outs
=
fn
(
*
args
)
if
not
(
type
(
next_outs
)
in
(
list
,
tuple
)):
if
not
(
type
(
next_outs
)
in
(
list
,
tuple
)):
next_outs
=
[
next_outs
]
next_outs
=
[
next_outs
]
# Create the Scan op object
# Create the Scan op object
local_op
=
Scan
(
(
args
,
next_outs
),
n_seqs
,
n_outs
,
inplace_map
,
local_op
=
Scan
(
(
args
,
next_outs
),
n_seqs
,
n_outs
,
inplace_map
,
sequences_taps
,
outputs_taps
,
truncate_gradient
,
sequences_taps
,
outputs_taps
,
truncate_gradient
,
go_backwards
,
stored_steps_output
,
mode
)
go_backwards
,
stored_steps_output
,
mode
)
...
@@ -362,8 +368,13 @@ class Scan(theano.Op):
...
@@ -362,8 +368,13 @@ class Scan(theano.Op):
else
:
else
:
out_types
+=
[
theano
.
tensor
.
Tensor
(
dtype
=
inputs
[
i
]
.
dtype
,
\
out_types
+=
[
theano
.
tensor
.
Tensor
(
dtype
=
inputs
[
i
]
.
dtype
,
\
broadcastable
=
(
False
,)
+
inputs
[
i
]
.
broadcastable
[
1
:])()]
broadcastable
=
(
False
,)
+
inputs
[
i
]
.
broadcastable
[
1
:])()]
else
:
else
:
out_types
+=
[
inputs
[
i
]
.
type
()]
if
self
.
stored_steps_output
[
i
-
1
-
self
.
n_seqs
]
!=
1
:
out_types
+=
[
theano
.
tensor
.
Tensor
(
dtype
=
inputs
[
i
]
.
dtype
,
broadcastable
=
(
False
,)
+
inputs
[
i
]
.
broadcastable
)()]
else
:
out_types
+=
[
theano
.
tensor
.
Tensor
(
dtype
=
inputs
[
i
]
.
dtype
,
broadcastable
=
inputs
[
i
]
.
broadcastable
)()]
else
:
else
:
raise
ValueError
((
'You need to provide initial state for outputs'
raise
ValueError
((
'You need to provide initial state for outputs'
' such that scan can infer what dataype they are'
))
' such that scan can infer what dataype they are'
))
...
@@ -374,7 +385,7 @@ class Scan(theano.Op):
...
@@ -374,7 +385,7 @@ class Scan(theano.Op):
rval
=
type
(
self
)
==
type
(
other
)
rval
=
type
(
self
)
==
type
(
other
)
if
rval
:
if
rval
:
rval
=
(
self
.
inputs
==
other
.
inputs
)
and
\
rval
=
(
self
.
inputs
==
other
.
inputs
)
and
\
(
self
.
outputs
==
other
.
outputs
)
and
\
(
self
.
outputs
==
other
.
outputs
)
and
\
(
self
.
stored_steps_output
==
other
.
stored_steps_output
)
and
\
(
self
.
stored_steps_output
==
other
.
stored_steps_output
)
and
\
(
self
.
seqs_taps
==
other
.
seqs_taps
)
and
\
(
self
.
seqs_taps
==
other
.
seqs_taps
)
and
\
(
self
.
outs_taps
==
other
.
outs_taps
)
and
\
(
self
.
outs_taps
==
other
.
outs_taps
)
and
\
...
@@ -408,7 +419,6 @@ class Scan(theano.Op):
...
@@ -408,7 +419,6 @@ class Scan(theano.Op):
def
perform
(
self
,
node
,
args
,
outs
):
def
perform
(
self
,
node
,
args
,
outs
):
n_steps
=
0
n_steps
=
0
if
(
self
.
n_seqs
==
0
)
and
(
args
[
0
]
==
0
):
if
(
self
.
n_seqs
==
0
)
and
(
args
[
0
]
==
0
):
raise
ValueError
(
'Scan does not know over how many steps it '
raise
ValueError
(
'Scan does not know over how many steps it '
...
@@ -605,7 +615,7 @@ def scan_make_inplace(node):
...
@@ -605,7 +615,7 @@ def scan_make_inplace(node):
op
=
node
.
op
op
=
node
.
op
if
isinstance
(
op
,
Scan
)
and
(
not
op
.
inplace
)
\
if
isinstance
(
op
,
Scan
)
and
(
not
op
.
inplace
)
\
and
(
op
.
inplace_map
.
keys
()
!=
[]):
and
(
op
.
inplace_map
.
keys
()
!=
[]):
return
Scan
((
op
.
inputs
,
op
.
outputs
)
,
op
.
n_seqs
,
return
Scan
((
op
.
inputs
,
op
.
outputs
)
,
op
.
n_seqs
,
op
.
n_outs
,
op
.
inplace_map
,
op
.
seqs_taps
,
op
.
outs_taps
,
op
.
n_outs
,
op
.
inplace_map
,
op
.
seqs_taps
,
op
.
outs_taps
,
op
.
truncate_gradient
,
op
.
go_backwards
,
op
.
stored_steps_output
,
op
.
truncate_gradient
,
op
.
go_backwards
,
op
.
stored_steps_output
,
inplace
=
True
inplace
=
True
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论