Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
cfaf41e0
提交
cfaf41e0
authored
11月 20, 2008
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code cleanup.
上级
7cdbf6e5
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
9 行增加
和
34 行删除
+9
-34
test_wiki.py
examples/tests/test_wiki.py
+9
-34
没有找到文件。
examples/tests/test_wiki.py
浏览文件 @
cfaf41e0
...
...
@@ -12,20 +12,15 @@ class Blah(M.ModuleInstance):
# super(Blah, self)
def
initialize
(
self
,
input_size
=
None
,
target_size
=
None
,
seed
=
1827
,
**
init
):
#super(Blah, self)#TODO: don't work
M
.
default_initialize
(
self
,
**
init
)
#equivalent to previous line.
if
input_size
and
target_size
:
# initialize w and b in a special way using input_size and target_size
sz
=
(
input_size
,
target_size
)
rng
=
N
.
random
.
RandomState
(
seed
)
self
.
w
=
rng
.
uniform
(
size
=
sz
,
low
=
-
0.5
,
high
=
0.5
)
self
.
b
=
N
.
zeros
(
target_size
)
#self.stepsize = 0.01#overwrite the value
if
not
hasattr
(
self
,
"stepsize"
):
self
.
stepsize
=
0.01
#we call super after as we want the parameter to superseed the default value.
#super(Blah, self)#don't overwrite the value.
#M.default_initialize(self,**init)#equivalent to previous line.
#we call default_initialize after as we want the parameter to superseed the default value.
M
.
default_initialize
(
self
,
**
init
)
#equivalent to previous line.
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
.
component
,
SoftmaxXERegression1
)
and
not
isinstance
(
other
.
component
,
SoftmaxXERegression2
):
raise
NotImplemented
...
...
@@ -119,22 +114,18 @@ class RegressionLayer2(M.Module):
seed
=
1827
,
**
init
):
# obj is an "instance" of this module holding values for each member and
# functions for each method
# here we call the default initialize method, which takes all the name: value
# pairs in init and sets the property with that name to the provided value
# this covers setting stepsize, l2_coef; w and b can be set that way too
M
.
default_initialize
(
obj
,
**
init
)
#will not overwrite the value!
if
input_size
and
target_size
:
# initialize w and b in a special way using input_size and target_size
sz
=
(
input_size
,
target_size
)
rng
=
N
.
random
.
RandomState
(
seed
)
obj
.
w
=
rng
.
uniform
(
size
=
sz
,
low
=
-
0.5
,
high
=
0.5
)
obj
.
b
=
N
.
zeros
(
target_size
)
#obj.stepsize = 0.01#would owerrite the value!
if
not
hasattr
(
obj
,
"stepsize"
):
obj
.
stepsize
=
0.01
#M.default_initialize(obj,**init)#will not overwrite the value!
# here we call the default_initialize method, which takes all the name: value
# pairs in init and sets the property with that name to the provided value
# this covers setting stepsize, l2_coef; w and b can be set that way too
# we call it after as we want the parameter to superseed the default value.
M
.
default_initialize
(
obj
,
**
init
)
def
build_regularization
(
self
):
return
T
.
zero
()
# no regularization!
...
...
@@ -318,21 +309,5 @@ class T_test_wiki_module(unittest.TestCase):
if
__name__
==
'__main__'
:
if
0
:
unittest
.
main
()
elif
1
:
module
=
__import__
(
"test_wiki"
)
tests
=
unittest
.
TestLoader
()
.
loadTestsFromModule
(
module
)
tests
.
debug
()
else
:
testcases
=
[]
testcases
.
append
(
T_function_module
)
#<testsuite boilerplate>
testloader
=
unittest
.
TestLoader
()
suite
=
unittest
.
TestSuite
()
for
testcase
in
testcases
:
suite
.
addTest
(
testloader
.
loadTestsFromTestCase
(
testcase
))
unittest
.
TextTestRunner
(
verbosity
=
2
)
.
run
(
suite
)
#</boilerplate>
from
theano.tests
import
main
main
(
"test_wiki"
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论