Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
75888e54
提交
75888e54
authored
11月 19, 2008
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
indentention and renamed fct.
上级
59caf2a0
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
8 行增加
和
8 行删除
+8
-8
test_wiki.py
examples/tests/test_wiki.py
+8
-8
没有找到文件。
examples/tests/test_wiki.py
浏览文件 @
75888e54
...
@@ -156,8 +156,8 @@ class SoftmaxXERegression2(RegressionLayer2):
...
@@ -156,8 +156,8 @@ class SoftmaxXERegression2(RegressionLayer2):
return
self
.
l2_coef
*
T
.
sum
(
self
.
w
*
self
.
w
)
return
self
.
l2_coef
*
T
.
sum
(
self
.
w
*
self
.
w
)
class
T_
function
_module
(
unittest
.
TestCase
):
class
T_
test_wiki
_module
(
unittest
.
TestCase
):
def
test_
Klass
_basic_example1
(
self
):
def
test_
Module
_basic_example1
(
self
):
n
,
c
=
T
.
scalars
(
'nc'
)
n
,
c
=
T
.
scalars
(
'nc'
)
inc
=
theano
.
function
([
n
,
((
c
,
c
+
n
),
0
)],
[])
inc
=
theano
.
function
([
n
,
((
c
,
c
+
n
),
0
)],
[])
dec
=
theano
.
function
([
n
,
((
c
,
c
-
n
),
inc
.
container
[
c
])],
[])
# we need to pass inc's container in order to share
dec
=
theano
.
function
([
n
,
((
c
,
c
-
n
),
inc
.
container
[
c
])],
[])
# we need to pass inc's container in order to share
...
@@ -169,7 +169,7 @@ class T_function_module(unittest.TestCase):
...
@@ -169,7 +169,7 @@ class T_function_module(unittest.TestCase):
assert
inc
[
c
]
==
-
1
and
dec
[
c
]
==
inc
[
c
]
assert
inc
[
c
]
==
-
1
and
dec
[
c
]
==
inc
[
c
]
assert
plus10
()
==
9
assert
plus10
()
==
9
def
test_
Klass
_basic_example2
(
self
):
def
test_
Module
_basic_example2
(
self
):
m
=
M
.
Module
()
m
=
M
.
Module
()
n
=
T
.
scalar
(
'n'
)
n
=
T
.
scalar
(
'n'
)
m
.
c
=
M
.
Member
(
T
.
scalar
())
# state variables must be wrapped with ModuleMember
m
.
c
=
M
.
Member
(
T
.
scalar
())
# state variables must be wrapped with ModuleMember
...
@@ -187,7 +187,7 @@ class T_function_module(unittest.TestCase):
...
@@ -187,7 +187,7 @@ class T_function_module(unittest.TestCase):
assert
inst
.
c
==
-
1
assert
inst
.
c
==
-
1
assert
inst
.
plus10
()
==
9
assert
inst
.
plus10
()
==
9
def
test_
Klass
_nesting_example1
(
self
):
def
test_
Module
_nesting_example1
(
self
):
def
make_incdec_function
():
def
make_incdec_function
():
n
,
c
=
T
.
scalars
(
'nc'
)
n
,
c
=
T
.
scalars
(
'nc'
)
inc
=
theano
.
function
([
n
,
((
c
,
c
+
n
),
0
)],
[])
inc
=
theano
.
function
([
n
,
((
c
,
c
+
n
),
0
)],
[])
...
@@ -205,7 +205,7 @@ class T_function_module(unittest.TestCase):
...
@@ -205,7 +205,7 @@ class T_function_module(unittest.TestCase):
assert
inc1
[
'c'
]
==
-
2
and
inc2
[
'c'
]
==
6
assert
inc1
[
'c'
]
==
-
2
and
inc2
[
'c'
]
==
6
assert
sum
()
==
4
# -2 + 6
assert
sum
()
==
4
# -2 + 6
def
test_
Klass
_nesting_example2
(
self
):
def
test_
Module
_nesting_example2
(
self
):
def
make_incdec_module
():
def
make_incdec_module
():
m
=
M
.
Module
()
m
=
M
.
Module
()
n
=
T
.
scalar
(
'n'
)
n
=
T
.
scalar
(
'n'
)
...
@@ -225,7 +225,7 @@ class T_function_module(unittest.TestCase):
...
@@ -225,7 +225,7 @@ class T_function_module(unittest.TestCase):
assert
inst
.
incdec1
.
c
==
-
2
and
inst
.
incdec2
.
c
==
6
assert
inst
.
incdec1
.
c
==
-
2
and
inst
.
incdec2
.
c
==
6
assert
inst
.
sum
()
==
4
# -2 + 6
assert
inst
.
sum
()
==
4
# -2 + 6
def
test_
Klass
_Advanced_example
(
self
):
def
test_
Module
_Advanced_example
(
self
):
data_x
=
N
.
random
.
randn
(
4
,
10
)
data_x
=
N
.
random
.
randn
(
4
,
10
)
data_y
=
[
[
int
(
x
)]
for
x
in
N
.
random
.
randn
(
4
)
>
0
]
data_y
=
[
[
int
(
x
)]
for
x
in
N
.
random
.
randn
(
4
)
>
0
]
# print data_x
# print data_x
...
@@ -257,7 +257,7 @@ class T_function_module(unittest.TestCase):
...
@@ -257,7 +257,7 @@ class T_function_module(unittest.TestCase):
print
m1
==
m2
print
m1
==
m2
assert
m2
==
m1
and
m1
==
m2
assert
m2
==
m1
and
m1
==
m2
def
test_
Klass
_extending_klass_methods
(
self
):
def
test_
Module
_extending_klass_methods
(
self
):
model_module
=
SoftmaxXERegression1
(
regularize
=
False
)
model_module
=
SoftmaxXERegression1
(
regularize
=
False
)
model_module
.
sum
=
M
.
Member
(
T
.
scalar
())
# we add a module member to hold the sum
model_module
.
sum
=
M
.
Member
(
T
.
scalar
())
# we add a module member to hold the sum
model_module
.
update
.
updates
.
update
(
sum
=
model_module
.
sum
+
model_module
.
cost
)
# now update will also update sum!
model_module
.
update
.
updates
.
update
(
sum
=
model_module
.
sum
+
model_module
.
cost
)
# now update will also update sum!
...
@@ -271,7 +271,7 @@ class T_function_module(unittest.TestCase):
...
@@ -271,7 +271,7 @@ class T_function_module(unittest.TestCase):
test
+=
model
.
update
([[
0
,
1
,
0
,
0
]],
[[
1
,
0
]])
test
+=
model
.
update
([[
0
,
1
,
0
,
0
]],
[[
1
,
0
]])
assert
model
.
sum
==
test
assert
model
.
sum
==
test
def
test_
Klass
_basic_example2_more
(
self
):
def
test_
Module
_basic_example2_more
(
self
):
m
=
M
.
Module
()
m
=
M
.
Module
()
m2
=
M
.
Module
()
m2
=
M
.
Module
()
m2
.
name
=
"m2"
# for better error
m2
.
name
=
"m2"
# for better error
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论