Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
790e1d59
提交
790e1d59
authored
6月 10, 2011
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Indent fix
上级
2c57dd29
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
29 行增加
和
29 行删除
+29
-29
test_naacl09.py
theano/tensor/tests/test_naacl09.py
+29
-29
没有找到文件。
theano/tensor/tests/test_naacl09.py
浏览文件 @
790e1d59
...
@@ -26,7 +26,7 @@ class QuadraticDenoisingAA(module.Module):
...
@@ -26,7 +26,7 @@ class QuadraticDenoisingAA(module.Module):
WRITEME
WRITEME
Abstract base class. Requires subclass with functions:
Abstract base class. Requires subclass with functions:
- build_corrupted_input()
- build_corrupted_input()
Introductory article about this model WRITEME.
Introductory article about this model WRITEME.
...
@@ -193,7 +193,7 @@ class QuadraticDenoisingAA(module.Module):
...
@@ -193,7 +193,7 @@ class QuadraticDenoisingAA(module.Module):
if
(
input_size
is
None
)
^
(
hidden_size
is
None
):
if
(
input_size
is
None
)
^
(
hidden_size
is
None
):
raise
ValueError
(
"Must specify input_size and hidden_size or neither."
)
raise
ValueError
(
"Must specify input_size and hidden_size or neither."
)
super
(
QuadraticDenoisingAA
,
self
)
.
_instance_initialize
(
obj
,
{})
super
(
QuadraticDenoisingAA
,
self
)
.
_instance_initialize
(
obj
,
{})
obj
.
random
.
initialize
()
obj
.
random
.
initialize
()
R
=
N
.
random
.
RandomState
(
unittest_tools
.
fetch_seed
(
seed
))
R
=
N
.
random
.
RandomState
(
unittest_tools
.
fetch_seed
(
seed
))
if
input_size
is
not
None
:
if
input_size
is
not
None
:
...
@@ -312,7 +312,7 @@ class Module_Nclass(module.FancyModule):
...
@@ -312,7 +312,7 @@ class Module_Nclass(module.FancyModule):
sum_xent
=
T
.
sum
(
xent
)
sum_xent
=
T
.
sum
(
xent
)
self
.
softmax
=
softmax
self
.
softmax
=
softmax
self
.
argmax
=
argmax
self
.
argmax
=
argmax
self
.
max_pr
=
max_pr
self
.
max_pr
=
max_pr
self
.
sum_xent
=
sum_xent
self
.
sum_xent
=
sum_xent
...
@@ -341,7 +341,7 @@ class Module_Nclass(module.FancyModule):
...
@@ -341,7 +341,7 @@ class Module_Nclass(module.FancyModule):
#updates = dict((p, p - self.lr * g) for p, g in zip(self.params, gparams)))
#updates = dict((p, p - self.lr * g) for p, g in zip(self.params, gparams)))
class
ConvolutionalMLP
(
module
.
FancyModule
):
class
ConvolutionalMLP
(
module
.
FancyModule
):
def
__init__
(
self
,
def
__init__
(
self
,
window_size
,
window_size
,
n_quadratic_filters
,
n_quadratic_filters
,
activation_function
,
activation_function
,
...
@@ -417,8 +417,8 @@ class ConvolutionalMLP(module.FancyModule):
...
@@ -417,8 +417,8 @@ class ConvolutionalMLP(module.FancyModule):
zip
(
input_pretraining_params
,
input_pretraining_gradients
)
\
zip
(
input_pretraining_params
,
input_pretraining_gradients
)
\
+
zip
(
hidden_pretraining_params
,
hidden_pretraining_gradients
))
+
zip
(
hidden_pretraining_params
,
hidden_pretraining_gradients
))
self
.
pretraining_update
=
module
.
Method
(
self
.
inputs
,
self
.
pretraining_update
=
module
.
Method
(
self
.
inputs
,
[
input_pretraining_cost
,
hidden_pretraining_cost
],
[
input_pretraining_cost
,
hidden_pretraining_cost
],
pretraining_updates
)
pretraining_updates
)
finetuning_params
=
\
finetuning_params
=
\
...
@@ -464,7 +464,7 @@ class ConvolutionalMLP(module.FancyModule):
...
@@ -464,7 +464,7 @@ class ConvolutionalMLP(module.FancyModule):
assert
(
i
.
w2
==
self
.
input_representations
[
0
]
.
w2
)
.
all
()
assert
(
i
.
w2
==
self
.
input_representations
[
0
]
.
w2
)
.
all
()
assert
(
i
.
b1
==
self
.
input_representations
[
0
]
.
b1
)
.
all
()
assert
(
i
.
b1
==
self
.
input_representations
[
0
]
.
b1
)
.
all
()
assert
(
i
.
b2
==
self
.
input_representations
[
0
]
.
b2
)
.
all
()
assert
(
i
.
b2
==
self
.
input_representations
[
0
]
.
b2
)
.
all
()
assert
N
.
all
((
a
==
b
)
.
all
()
for
a
,
b
in
zip
(
i
.
qfilters
,
self
.
input_representations
[
0
]
.
qfilters
))
assert
N
.
all
((
a
==
b
)
.
all
()
for
a
,
b
in
zip
(
i
.
qfilters
,
self
.
input_representations
[
0
]
.
qfilters
))
self
.
hidden
.
initialize
(
input_size
=
(
len
(
self
.
inputs
)
*
self
.
input_representation_size
),
self
.
hidden
.
initialize
(
input_size
=
(
len
(
self
.
inputs
)
*
self
.
input_representation_size
),
hidden_size
=
self
.
hidden_representation_size
,
noise_level
=
noise_level
,
hidden_size
=
self
.
hidden_representation_size
,
noise_level
=
noise_level
,
...
@@ -472,16 +472,16 @@ class ConvolutionalMLP(module.FancyModule):
...
@@ -472,16 +472,16 @@ class ConvolutionalMLP(module.FancyModule):
self
.
output
.
initialize
(
n_in
=
self
.
hidden_representation_size
,
n_out
=
self
.
output_size
,
lr
=
lr
,
seed
=
R
.
random_integers
(
2
**
30
))
self
.
output
.
initialize
(
n_in
=
self
.
hidden_representation_size
,
n_out
=
self
.
output_size
,
lr
=
lr
,
seed
=
R
.
random_integers
(
2
**
30
))
def
create
(
window_size
=
3
,
def
create
(
window_size
=
3
,
input_dimension
=
9
,
input_dimension
=
9
,
output_vocabsize
=
8
,
output_vocabsize
=
8
,
n_quadratic_filters
=
2
,
n_quadratic_filters
=
2
,
token_representation_size
=
5
,
token_representation_size
=
5
,
concatenated_representation_size
=
7
,
concatenated_representation_size
=
7
,
lr
=
0.01
,
lr
=
0.01
,
seed
=
123
,
seed
=
123
,
noise_level
=
0.2
,
noise_level
=
0.2
,
qfilter_relscale
=
0.1
,
qfilter_relscale
=
0.1
,
compile_mode
=
None
):
compile_mode
=
None
):
""" Create a convolutional model. """
""" Create a convolutional model. """
activation_function
=
T
.
tanh
activation_function
=
T
.
tanh
...
@@ -503,15 +503,15 @@ def create(window_size=3,
...
@@ -503,15 +503,15 @@ def create(window_size=3,
return
model
return
model
def
create_realistic
(
window_size
=
3
,
#7,
def
create_realistic
(
window_size
=
3
,
#7,
input_dimension
=
200
,
input_dimension
=
200
,
output_vocabsize
=
23
,
output_vocabsize
=
23
,
n_quadratic_filters
=
2
,
n_quadratic_filters
=
2
,
token_representation_size
=
150
,
token_representation_size
=
150
,
concatenated_representation_size
=
400
,
concatenated_representation_size
=
400
,
lr
=
0.001
,
lr
=
0.001
,
seed
=
123
,
seed
=
123
,
noise_level
=
0.2
,
noise_level
=
0.2
,
qfilter_relscale
=
0.1
,
qfilter_relscale
=
0.1
,
compile_mode
=
None
):
compile_mode
=
None
):
""" Create a convolutional model. """
""" Create a convolutional model. """
activation_function
=
T
.
tanh
activation_function
=
T
.
tanh
...
@@ -531,7 +531,7 @@ def test_naacl_model(iters_per_unsup=3, iters_per_sup=3,
...
@@ -531,7 +531,7 @@ def test_naacl_model(iters_per_unsup=3, iters_per_sup=3,
print
"BUILDING MODEL"
print
"BUILDING MODEL"
import
time
import
time
t
=
time
.
time
()
t
=
time
.
time
()
if
optimizer
:
if
optimizer
:
mode
=
theano
.
Mode
(
linker
=
'c|py'
,
optimizer
=
optimizer
)
mode
=
theano
.
Mode
(
linker
=
'c|py'
,
optimizer
=
optimizer
)
else
:
mode
=
get_default_mode
()
else
:
mode
=
get_default_mode
()
...
@@ -539,7 +539,7 @@ def test_naacl_model(iters_per_unsup=3, iters_per_sup=3,
...
@@ -539,7 +539,7 @@ def test_naacl_model(iters_per_unsup=3, iters_per_sup=3,
if
mode
.
__class__
.
__name__
==
'DebugMode'
:
if
mode
.
__class__
.
__name__
==
'DebugMode'
:
iters_per_unsup
=
1
iters_per_unsup
=
1
iters_per_sup
=
1
iters_per_sup
=
1
if
realistic
:
if
realistic
:
m
=
create_realistic
(
compile_mode
=
mode
)
m
=
create_realistic
(
compile_mode
=
mode
)
else
:
else
:
...
@@ -602,7 +602,7 @@ def real_main():
...
@@ -602,7 +602,7 @@ def real_main():
test_naacl_model
()
test_naacl_model
()
def
profile_main
():
def
profile_main
():
# This is the main function for profiling
# This is the main function for profiling
# We've renamed our original main() above to real_main()
# We've renamed our original main() above to real_main()
import
cProfile
,
pstats
,
StringIO
import
cProfile
,
pstats
,
StringIO
prof
=
cProfile
.
Profile
()
prof
=
cProfile
.
Profile
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论