Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
68e0fea1
提交
68e0fea1
authored
5月 18, 2011
作者:
Razvan Pascanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't force variables to have a name field .. but rather first check if
there is one or not.
上级
d1c51b24
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
17 行增加
和
19 行删除
+17
-19
scan.py
theano/scan_module/scan.py
+7
-9
scan_op.py
theano/scan_module/scan_op.py
+10
-10
没有找到文件。
theano/scan_module/scan.py
浏览文件 @
68e0fea1
...
...
@@ -371,7 +371,7 @@ def scan( fn
# ^ explicitly provided a None for taps
warning
(
' Output
%
s ( index
%
d) has a initial state '
' but taps is explicitly set to None '
%
(
outs_info
[
i
][
'initial'
]
.
name
getattr
(
outs_info
[
i
][
'initial'
],
'name'
,
'None'
)
,
i
)
)
outs_info
[
i
][
'taps'
]
=
[
-
1
]
else
:
...
...
@@ -416,12 +416,10 @@ def scan( fn
nw_slice
=
seq
[
'input'
][
0
]
.
type
()
actual_slice
=
seq
[
'input'
][
k
-
mintap
]
if
not
hasattr
(
seq
[
'input'
],
'name'
):
raise
TypeError
(
'Expected object with a "name" field, got '
+
str
(
seq
)
+
"['input'] = "
+
str
(
seq
[
'input'
]))
# Add names to slices for debugging and pretty printing ..
# that is if the input already has a name
if
seq
[
'input'
]
.
nam
e
:
if
getattr
(
seq
[
'input'
],
'name'
,
None
)
is
not
Non
e
:
if
k
>
0
:
nw_name
=
seq
[
'input'
]
.
name
+
'[t+
%
d]'
%
k
elif
k
==
0
:
...
...
@@ -481,7 +479,7 @@ def scan( fn
# Add names -- it helps a lot when debugging
for
(
nw_seq
,
seq
)
in
zip
(
scan_seqs
,
seqs
):
if
seq
[
'input'
]
.
nam
e
:
if
getattr
(
seq
[
'input'
],
'name'
,
None
)
is
not
Non
e
:
nw_seq
.
name
=
seq
[
'input'
]
.
name
+
'[
%
d:]'
%
k
# Conventions :
...
...
@@ -534,7 +532,7 @@ def scan( fn
actual_arg
=
init_out
[
'initial'
]
arg
=
safe_new
(
init_out
[
'initial'
])
if
init_out
[
'initial'
]
.
nam
e
:
if
getattr
(
init_out
[
'initial'
],
'name'
,
None
)
is
not
Non
e
:
arg
.
name
=
init_out
[
'initial'
]
.
name
+
'[t-1]'
# We need now to allocate space for storing the output and copy
# the initial state over. We do this using the expand function
...
...
@@ -579,7 +577,7 @@ def scan( fn
nw_slice
=
init_out
[
'initial'
][
0
]
.
type
()
# give it a name or debugging and pretty printing
if
init_out
[
'initial'
]
.
nam
e
:
if
getattr
(
init_out
[
'initial'
],
'name'
,
None
)
is
not
Non
e
:
if
k
>
0
:
nw_slice
.
name
=
(
init_out
[
'initial'
]
.
name
+
'[t+
%
d]'
%
k
)
...
...
@@ -746,7 +744,7 @@ def scan( fn
for
input
in
dummy_f
.
maker
.
expanded_inputs
:
if
isinstance
(
input
.
variable
,
SharedVariable
)
and
input
.
update
:
new_var
=
safe_new
(
input
.
variable
)
if
input
.
variable
.
nam
e
:
if
getattr
(
input
.
variable
,
'name'
,
None
)
is
not
Non
e
:
new_var
.
name
=
input
.
variable
.
name
+
'_copy'
shared_inner_inputs
.
append
(
new_var
)
shared_scan_inputs
.
append
(
input
.
variable
)
...
...
@@ -777,7 +775,7 @@ def scan( fn
## Step 5.6 all shared variables with no update rules
def
new_variable
(
v
):
new_v
=
safe_new
(
v
)
if
v
.
nam
e
:
if
getattr
(
v
,
'name'
,
None
)
is
not
Non
e
:
new_v
.
name
=
v
.
name
+
'_copy'
return
new_v
other_inner_args
+=
[
new_variable
(
arg
)
for
arg
in
non_seqs
...
...
theano/scan_module/scan_op.py
浏览文件 @
68e0fea1
...
...
@@ -226,10 +226,10 @@ class Scan(Op):
for
idx
in
xrange
(
self
.
n_seqs
):
if
inputs
[
1
+
idx
]
.
dtype
!=
self
.
inputs
[
idx
]
.
dtype
:
raise
ValueError
(
err_msg1
%
(
'Sequence'
,
inputs
[
1
+
idx
]
.
name
,
str
(
inputs
[
1
+
idx
])
,
idx
,
inputs
[
1
+
idx
]
.
dtype
,
s
elf
.
inputs
[
idx
]
.
name
,
s
tr
(
self
.
inputs
[
idx
])
,
self
.
inputs
[
idx
]
.
dtype
)
)
# Check that this 3 things have the same dtype for mit_mot:
...
...
@@ -246,10 +246,10 @@ class Scan(Op):
for
k
in
self
.
tap_array
[
index
-
start
]:
if
inputs
[
index
]
.
dtype
!=
self
.
inputs
[
index_i
]
.
dtype
:
raise
ValueError
(
err_msg1
%
(
'Initial state'
,
inputs
[
index
]
.
name
,
str
(
inputs
[
index
])
,
index
,
inputs
[
index
]
.
dtype
,
s
elf
.
inputs
[
index_i
]
.
name
,
s
tr
(
self
.
inputs
[
index_i
])
,
self
.
inputs
[
index_i
]
.
dtype
)
)
index_i
+=
1
for
k
in
self
.
mit_mot_out_slices
[
index
-
start
]:
...
...
@@ -266,14 +266,14 @@ class Scan(Op):
for
k
in
self
.
tap_array
[
index
-
start
]:
if
inputs
[
index
]
.
dtype
!=
self
.
inputs
[
index_i
]
.
dtype
:
raise
ValueError
(
err_msg1
%
(
'Initial state'
,
inputs
[
index
]
.
name
,
str
(
inputs
[
index
])
,
index
,
inputs
[
index
]
.
dtype
,
s
elf
.
inputs
[
index_i
]
.
name
,
s
tr
(
self
.
inputs
[
index_i
])
,
self
.
inputs
[
index_i
]
.
dtype
)
)
index_i
+=
1
if
inputs
[
index
]
.
dtype
!=
self
.
outputs
[
index_o
]
.
dtype
:
raise
ValueError
(
err_msg2
%
(
inputs
[
index
]
.
name
raise
ValueError
(
err_msg2
%
(
str
(
inputs
[
index
])
,
index
,
inputs
[
index
]
.
dtype
,
self
.
outputs
[
index_o
]
.
dtype
)
)
...
...
@@ -287,7 +287,7 @@ class Scan(Op):
while
index
<
end
:
if
(
hasattr
(
inputs
[
index
],
'dtype'
)
and
inputs
[
index
]
.
dtype
!=
self
.
outputs
[
index_o
]
.
dtype
):
raise
ValueError
(
err_msg2
%
(
inputs
[
index
]
.
name
raise
ValueError
(
err_msg2
%
(
str
(
inputs
[
index
])
,
index
,
inputs
[
index
]
.
dtype
,
self
.
outputs
[
index_o
]
.
dtype
)
)
...
...
@@ -794,7 +794,7 @@ class Scan(Op):
g_out_slices
.
append
(
g_outs_no_shared
[
dx
][
0
])
else
:
g_out_slices
.
append
(
None
)
if
out
.
nam
e
:
if
getattr
(
out
,
'name'
,
None
)
is
not
Non
e
:
inner_g_out
.
name
=
'g_'
+
out
.
name
else
:
inner_g_out
.
name
=
'g_'
+
str
(
dx
)
...
...
@@ -872,7 +872,7 @@ class Scan(Op):
nw_seq
=
seq
[
dim_offset
+
k
-
mintap
:
-
(
maxtap
-
k
)]
else
:
nw_seq
=
seq
[
dim_offset
+
k
-
mintap
:
]
if
seq
.
nam
e
:
if
getattr
(
seq
,
'name'
,
None
)
is
not
Non
e
:
nw_seq
.
name
=
seq
.
name
+
'[
%
d:]'
%
k
scan_seqs
.
append
(
nw_seq
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论