Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f06bd5d1
提交
f06bd5d1
authored
4月 02, 2011
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Indentation and whitespace.
上级
c63fe0ea
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
40 行增加
和
54 行删除
+40
-54
test_debugmode.py
theano/compile/tests/test_debugmode.py
+0
-1
test_misc.py
theano/compile/tests/test_misc.py
+23
-24
solve.py
theano/sandbox/solve.py
+0
-1
test_basic.py
theano/scalar/tests/test_basic.py
+2
-6
truedot.py
theano/sparse/sandbox/truedot.py
+0
-1
test_conv.py
theano/tensor/signal/tests/test_conv.py
+3
-3
test_casting.py
theano/tensor/tests/test_casting.py
+2
-2
test_inc_subtensor.py
theano/tensor/tests/test_inc_subtensor.py
+5
-8
test_incsubtensor.py
theano/tensor/tests/test_incsubtensor.py
+5
-8
没有找到文件。
theano/compile/tests/test_debugmode.py
浏览文件 @
f06bd5d1
...
@@ -505,4 +505,3 @@ class Test_check_isfinite(unittest.TestCase):
...
@@ -505,4 +505,3 @@ class Test_check_isfinite(unittest.TestCase):
print
infs
print
infs
f
(
infs
)
f
(
infs
)
return
return
theano/compile/tests/test_misc.py
浏览文件 @
f06bd5d1
...
@@ -7,35 +7,35 @@ from theano.tensor.nnet import sigmoid
...
@@ -7,35 +7,35 @@ from theano.tensor.nnet import sigmoid
class
NNet
(
object
):
class
NNet
(
object
):
def
__init__
(
self
,
def
__init__
(
self
,
input
=
tensor
.
dvector
(
'input'
),
input
=
tensor
.
dvector
(
'input'
),
target
=
tensor
.
dvector
(
'target'
),
target
=
tensor
.
dvector
(
'target'
),
n_input
=
1
,
n_hidden
=
1
,
n_output
=
1
,
lr
=
1e-3
,
**
kw
):
n_input
=
1
,
n_hidden
=
1
,
n_output
=
1
,
lr
=
1e-3
,
**
kw
):
super
(
NNet
,
self
)
.
__init__
(
**
kw
)
super
(
NNet
,
self
)
.
__init__
(
**
kw
)
self
.
input
=
input
self
.
input
=
input
self
.
target
=
target
self
.
target
=
target
self
.
lr
=
shared
(
lr
,
'learning_rate'
)
self
.
lr
=
shared
(
lr
,
'learning_rate'
)
self
.
w1
=
shared
(
numpy
.
zeros
((
n_hidden
,
n_input
)),
'w1'
)
self
.
w1
=
shared
(
numpy
.
zeros
((
n_hidden
,
n_input
)),
'w1'
)
self
.
w2
=
shared
(
numpy
.
zeros
((
n_output
,
n_hidden
)),
'w2'
)
self
.
w2
=
shared
(
numpy
.
zeros
((
n_output
,
n_hidden
)),
'w2'
)
print
self
.
lr
.
type
print
self
.
lr
.
type
self
.
hidden
=
sigmoid
(
tensor
.
dot
(
self
.
w1
,
self
.
input
))
self
.
hidden
=
sigmoid
(
tensor
.
dot
(
self
.
w1
,
self
.
input
))
self
.
output
=
tensor
.
dot
(
self
.
w2
,
self
.
hidden
)
self
.
output
=
tensor
.
dot
(
self
.
w2
,
self
.
hidden
)
self
.
cost
=
tensor
.
sum
((
self
.
output
-
self
.
target
)
**
2
)
self
.
cost
=
tensor
.
sum
((
self
.
output
-
self
.
target
)
**
2
)
self
.
sgd_updates
=
{
self
.
sgd_updates
=
{
self
.
w1
:
self
.
w1
-
self
.
lr
*
tensor
.
grad
(
self
.
cost
,
self
.
w1
),
self
.
w1
:
self
.
w1
-
self
.
lr
*
tensor
.
grad
(
self
.
cost
,
self
.
w1
),
self
.
w2
:
self
.
w2
-
self
.
lr
*
tensor
.
grad
(
self
.
cost
,
self
.
w2
)}
self
.
w2
:
self
.
w2
-
self
.
lr
*
tensor
.
grad
(
self
.
cost
,
self
.
w2
)}
self
.
sgd_step
=
pfunc
(
self
.
sgd_step
=
pfunc
(
params
=
[
self
.
input
,
self
.
target
],
params
=
[
self
.
input
,
self
.
target
],
outputs
=
[
self
.
output
,
self
.
cost
],
outputs
=
[
self
.
output
,
self
.
cost
],
updates
=
self
.
sgd_updates
)
updates
=
self
.
sgd_updates
)
self
.
compute_output
=
pfunc
([
self
.
input
],
self
.
output
)
self
.
compute_output
=
pfunc
([
self
.
input
],
self
.
output
)
self
.
output_from_hidden
=
pfunc
([
self
.
hidden
],
self
.
output
)
self
.
output_from_hidden
=
pfunc
([
self
.
hidden
],
self
.
output
)
class
TestNnet
(
unittest
.
TestCase
):
class
TestNnet
(
unittest
.
TestCase
):
...
@@ -56,4 +56,3 @@ class TestNnet(unittest.TestCase):
...
@@ -56,4 +56,3 @@ class TestNnet(unittest.TestCase):
# Just call functions to make sure they do not crash.
# Just call functions to make sure they do not crash.
out
=
nnet
.
compute_output
(
input
)
out
=
nnet
.
compute_output
(
input
)
out
=
nnet
.
output_from_hidden
(
numpy
.
ones
(
10
))
out
=
nnet
.
output_from_hidden
(
numpy
.
ones
(
10
))
theano/sandbox/solve.py
浏览文件 @
f06bd5d1
...
@@ -62,4 +62,3 @@ class T_solve(unittest.TestCase):
...
@@ -62,4 +62,3 @@ class T_solve(unittest.TestCase):
self
.
assertTrue
(
numpy
.
all
(
are
<
1.0e-5
),
(
are
,
Ax
,
b
))
self
.
assertTrue
(
numpy
.
all
(
are
<
1.0e-5
),
(
are
,
Ax
,
b
))
#print A,b
#print A,b
#print numpy.dot(A,x)
#print numpy.dot(A,x)
theano/scalar/tests/test_basic.py
浏览文件 @
f06bd5d1
...
@@ -39,7 +39,7 @@ class test_ScalarOps(unittest.TestCase):
...
@@ -39,7 +39,7 @@ class test_ScalarOps(unittest.TestCase):
#so this is not a silent bug.
#so this is not a silent bug.
def
tes_mod
(
self
):
def
tes_mod
(
self
):
"""
"""
We add this test as not all language and C implementation give the same
We add this test as not all language and C implementation give the same
signe to the result. This check that the c_code of `Mod` is implemented
signe to the result. This check that the c_code of `Mod` is implemented
as Python. That is what we want.
as Python. That is what we want.
"""
"""
...
@@ -161,7 +161,7 @@ class test_logical(unittest.TestCase):
...
@@ -161,7 +161,7 @@ class test_logical(unittest.TestCase):
fn
=
gof
.
DualLinker
()
.
accept
(
Env
([
x
,
y
],
[
x
&
y
]))
.
make_function
()
fn
=
gof
.
DualLinker
()
.
accept
(
Env
([
x
,
y
],
[
x
&
y
]))
.
make_function
()
for
a
,
b
in
((
0
,
1
),
(
0
,
0
),
(
1
,
0
),
(
1
,
1
)):
for
a
,
b
in
((
0
,
1
),
(
0
,
0
),
(
1
,
0
),
(
1
,
1
)):
self
.
assertTrue
(
fn
(
a
,
b
)
==
(
a
&
b
),
(
a
,
b
))
self
.
assertTrue
(
fn
(
a
,
b
)
==
(
a
&
b
),
(
a
,
b
))
def
test_not
(
self
):
def
test_not
(
self
):
x
,
y
,
z
=
ints
(
'xyz'
)
x
,
y
,
z
=
ints
(
'xyz'
)
fn
=
gof
.
DualLinker
()
.
accept
(
Env
([
x
,
y
],
[
invert
(
x
)]))
.
make_function
()
fn
=
gof
.
DualLinker
()
.
accept
(
Env
([
x
,
y
],
[
invert
(
x
)]))
.
make_function
()
...
@@ -196,7 +196,3 @@ class test_div(unittest.TestCase):
...
@@ -196,7 +196,3 @@ class test_div(unittest.TestCase):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
theano/sparse/sandbox/truedot.py
浏览文件 @
f06bd5d1
...
@@ -240,4 +240,3 @@ class test_true_dot(unittest.TestCase):
...
@@ -240,4 +240,3 @@ class test_true_dot(unittest.TestCase):
w
=
w
-
(
lr
*
gw
)
w
=
w
-
(
lr
*
gw
)
self
.
assertTrue
(
origloss
>
loss
)
self
.
assertTrue
(
origloss
>
loss
)
theano/tensor/signal/tests/test_conv.py
浏览文件 @
f06bd5d1
...
@@ -16,7 +16,7 @@ class TestSignalConv2D(unittest.TestCase):
...
@@ -16,7 +16,7 @@ class TestSignalConv2D(unittest.TestCase):
utt
.
seed_rng
()
utt
.
seed_rng
()
def
validate
(
self
,
image_shape
,
filter_shape
,
verify_grad
=
True
):
def
validate
(
self
,
image_shape
,
filter_shape
,
verify_grad
=
True
):
image_dim
=
len
(
image_shape
)
image_dim
=
len
(
image_shape
)
filter_dim
=
len
(
filter_shape
)
filter_dim
=
len
(
filter_shape
)
input
=
T
.
TensorType
(
'float64'
,
[
False
]
*
image_dim
)()
input
=
T
.
TensorType
(
'float64'
,
[
False
]
*
image_dim
)()
...
@@ -33,12 +33,12 @@ class TestSignalConv2D(unittest.TestCase):
...
@@ -33,12 +33,12 @@ class TestSignalConv2D(unittest.TestCase):
return
conv
.
conv2d
(
input
,
filters
)
return
conv
.
conv2d
(
input
,
filters
)
output
=
sym_conv2d
(
input
,
filters
)
output
=
sym_conv2d
(
input
,
filters
)
theano_conv
=
theano
.
function
([
input
,
filters
],
output
)
theano_conv
=
theano
.
function
([
input
,
filters
],
output
)
# initialize input and compute result
# initialize input and compute result
image_data
=
numpy
.
random
.
random
(
image_shape
)
image_data
=
numpy
.
random
.
random
(
image_shape
)
filter_data
=
numpy
.
random
.
random
(
filter_shape
)
filter_data
=
numpy
.
random
.
random
(
filter_shape
)
theano_output
=
theano_conv
(
image_data
,
filter_data
)
theano_output
=
theano_conv
(
image_data
,
filter_data
)
############# REFERENCE IMPLEMENTATION ############
############# REFERENCE IMPLEMENTATION ############
out_shape2d
=
numpy
.
array
(
image_shape
[
-
2
:])
-
\
out_shape2d
=
numpy
.
array
(
image_shape
[
-
2
:])
-
\
numpy
.
array
(
filter_shape
[
-
2
:])
+
1
numpy
.
array
(
filter_shape
[
-
2
:])
+
1
...
...
theano/tensor/tests/test_casting.py
浏览文件 @
f06bd5d1
...
@@ -45,7 +45,7 @@ class test_casting(unittest.TestCase):
...
@@ -45,7 +45,7 @@ class test_casting(unittest.TestCase):
f
=
function
([
a
],
basic
.
_convert_to_complex128
(
a
))
f
=
function
([
a
],
basic
.
_convert_to_complex128
(
a
))
#we need to compare with the same type.
#we need to compare with the same type.
assert
a
.
type
.
values_eq_approx
(
b
.
data
,
f
(
a
.
data
))
assert
a
.
type
.
values_eq_approx
(
b
.
data
,
f
(
a
.
data
))
f
=
function
([
b
],
basic
.
_convert_to_complex128
(
b
))
f
=
function
([
b
],
basic
.
_convert_to_complex128
(
b
))
assert
b
.
type
.
values_eq_approx
(
b
.
data
,
f
(
b
.
data
))
assert
b
.
type
.
values_eq_approx
(
b
.
data
,
f
(
b
.
data
))
...
@@ -77,7 +77,7 @@ class test_casting(unittest.TestCase):
...
@@ -77,7 +77,7 @@ class test_casting(unittest.TestCase):
f
=
function
([
a
],
basic
.
_convert_to_complex64
(
a
))
f
=
function
([
a
],
basic
.
_convert_to_complex64
(
a
))
assert
a
.
type
.
values_eq_approx
(
b
.
data
,
f
(
a
.
data
))
assert
a
.
type
.
values_eq_approx
(
b
.
data
,
f
(
a
.
data
))
def
test_bug_complext_10_august_09
(
self
):
def
test_bug_complext_10_august_09
(
self
):
v0
=
dmatrix
()
v0
=
dmatrix
()
v1
=
basic
.
_convert_to_complex128
(
v0
)
v1
=
basic
.
_convert_to_complex128
(
v0
)
...
...
theano/tensor/tests/test_inc_subtensor.py
浏览文件 @
f06bd5d1
...
@@ -9,7 +9,7 @@ class Test_inc_subtensor(unittest.TestCase):
...
@@ -9,7 +9,7 @@ class Test_inc_subtensor(unittest.TestCase):
What could be tested:
What could be tested:
- increment vs set
- increment vs set
- thing incremented: scalar, vector, matrix,
- thing incremented: scalar, vector, matrix,
- increment/set: constant, scalar, vector, matrix
- increment/set: constant, scalar, vector, matrix
- indices: scalar vs slice, constant vs variable, out of bound, ...
- indices: scalar vs slice, constant vs variable, out of bound, ...
- inplace
- inplace
...
@@ -50,7 +50,7 @@ class Test_inc_subtensor(unittest.TestCase):
...
@@ -50,7 +50,7 @@ class Test_inc_subtensor(unittest.TestCase):
expected_result
[:,:
val_sl2_end
]
=
val_inc
expected_result
[:,:
val_sl2_end
]
=
val_inc
else
:
else
:
expected_result
[:,:
val_sl2_end
]
+=
val_inc
expected_result
[:,:
val_sl2_end
]
+=
val_inc
self
.
assertTrue
(
numpy
.
array_equal
(
result
,
expected_result
))
self
.
assertTrue
(
numpy
.
array_equal
(
result
,
expected_result
))
return
return
...
@@ -68,20 +68,17 @@ class Test_inc_subtensor(unittest.TestCase):
...
@@ -68,20 +68,17 @@ class Test_inc_subtensor(unittest.TestCase):
# vector
# vector
utt
.
verify_grad
(
utt
.
verify_grad
(
inc_slice
(
slice
(
2
,
4
,
None
)),
inc_slice
(
slice
(
2
,
4
,
None
)),
(
numpy
.
asarray
([
0
,
1
,
2
,
3
,
4
,
5.
]),
(
numpy
.
asarray
([
0
,
1
,
2
,
3
,
4
,
5.
]),
numpy
.
asarray
([
9
,
9.
]),))
numpy
.
asarray
([
9
,
9.
]),))
# matrix
# matrix
utt
.
verify_grad
(
utt
.
verify_grad
(
inc_slice
(
slice
(
1
,
2
,
None
),
slice
(
None
,
None
,
None
)),
inc_slice
(
slice
(
1
,
2
,
None
),
slice
(
None
,
None
,
None
)),
(
numpy
.
asarray
([[
0
,
1
],[
2
,
3
],[
4
,
5.
]]),
(
numpy
.
asarray
([[
0
,
1
],[
2
,
3
],[
4
,
5.
]]),
numpy
.
asarray
([[
9
,
9.
]]),))
numpy
.
asarray
([[
9
,
9.
]]),))
#single element
#single element
utt
.
verify_grad
(
utt
.
verify_grad
(
inc_slice
(
2
,
1
),
inc_slice
(
2
,
1
),
(
numpy
.
asarray
([[
0
,
1
],[
2
,
3
],[
4
,
5.
]]),
(
numpy
.
asarray
([[
0
,
1
],[
2
,
3
],[
4
,
5.
]]),
numpy
.
asarray
(
9.
),))
numpy
.
asarray
(
9.
),))
theano/tensor/tests/test_incsubtensor.py
浏览文件 @
f06bd5d1
...
@@ -9,7 +9,7 @@ class Test_incsubtensor(unittest.TestCase):
...
@@ -9,7 +9,7 @@ class Test_incsubtensor(unittest.TestCase):
What could be tested:
What could be tested:
- increment vs set
- increment vs set
- thing incremented: scalar, vector, matrix,
- thing incremented: scalar, vector, matrix,
- increment/set: constant, scalar, vector, matrix
- increment/set: constant, scalar, vector, matrix
- indices: scalar vs slice, constant vs variable, out of bound, ...
- indices: scalar vs slice, constant vs variable, out of bound, ...
- inplace
- inplace
...
@@ -47,7 +47,7 @@ class Test_incsubtensor(unittest.TestCase):
...
@@ -47,7 +47,7 @@ class Test_incsubtensor(unittest.TestCase):
expected_result
[:,:
val_sl2_end
]
=
val_inc
expected_result
[:,:
val_sl2_end
]
=
val_inc
else
:
else
:
expected_result
[:,:
val_sl2_end
]
+=
val_inc
expected_result
[:,:
val_sl2_end
]
+=
val_inc
self
.
assertTrue
(
numpy
.
array_equal
(
result
,
expected_result
))
self
.
assertTrue
(
numpy
.
array_equal
(
result
,
expected_result
))
return
return
...
@@ -65,20 +65,17 @@ class Test_incsubtensor(unittest.TestCase):
...
@@ -65,20 +65,17 @@ class Test_incsubtensor(unittest.TestCase):
# vector
# vector
utt
.
verify_grad
(
utt
.
verify_grad
(
inc_slice
(
slice
(
2
,
4
,
None
)),
inc_slice
(
slice
(
2
,
4
,
None
)),
(
numpy
.
asarray
([
0
,
1
,
2
,
3
,
4
,
5.
]),
(
numpy
.
asarray
([
0
,
1
,
2
,
3
,
4
,
5.
]),
numpy
.
asarray
([
9
,
9.
]),))
numpy
.
asarray
([
9
,
9.
]),))
# matrix
# matrix
utt
.
verify_grad
(
utt
.
verify_grad
(
inc_slice
(
slice
(
1
,
2
,
None
),
slice
(
None
,
None
,
None
)),
inc_slice
(
slice
(
1
,
2
,
None
),
slice
(
None
,
None
,
None
)),
(
numpy
.
asarray
([[
0
,
1
],[
2
,
3
],[
4
,
5.
]]),
(
numpy
.
asarray
([[
0
,
1
],[
2
,
3
],[
4
,
5.
]]),
numpy
.
asarray
([[
9
,
9.
]]),))
numpy
.
asarray
([[
9
,
9.
]]),))
#single element
#single element
utt
.
verify_grad
(
utt
.
verify_grad
(
inc_slice
(
2
,
1
),
inc_slice
(
2
,
1
),
(
numpy
.
asarray
([[
0
,
1
],[
2
,
3
],[
4
,
5.
]]),
(
numpy
.
asarray
([[
0
,
1
],[
2
,
3
],[
4
,
5.
]]),
numpy
.
asarray
(
9.
),))
numpy
.
asarray
(
9.
),))
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论