Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0b5dbed9
提交
0b5dbed9
authored
2月 25, 2016
作者:
Olivier Mastropietro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed the PEP8 Error. Modified some tests to meet the standards without changing the output
上级
0aa5ff77
全部展开
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
43 行增加
和
42 行删除
+43
-42
test_builders.py
theano/compile/tests/test_builders.py
+19
-20
test_debugmode.py
theano/compile/tests/test_debugmode.py
+9
-9
test_function_module.py
theano/compile/tests/test_function_module.py
+0
-0
test_misc.py
theano/compile/tests/test_misc.py
+6
-3
test_monitormode.py
theano/compile/tests/test_monitormode.py
+1
-1
test_pfunc.py
theano/compile/tests/test_pfunc.py
+4
-4
test_profiling.py
theano/compile/tests/test_profiling.py
+3
-3
test_shared.py
theano/compile/tests/test_shared.py
+1
-2
没有找到文件。
theano/compile/tests/test_builders.py
浏览文件 @
0b5dbed9
...
...
@@ -4,7 +4,6 @@ from theano import config, shared
from
theano.compile
import
function
from
theano
import
tensor
from
theano
import
tensor
as
T
from
theano.tensor.shared_randomstreams
import
RandomStreams
...
...
@@ -24,8 +23,8 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
fn
=
function
([
x
,
y
,
z
],
f
)
xv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
# print function, function.__module__
# print fn.maker.fgraph.toposort()
fn
(
xv
,
yv
,
zv
)
...
...
@@ -39,8 +38,8 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
f
=
op
(
x
,
op
(
y
,
z
))
fn
=
function
([
x
,
y
,
z
],
f
)
xv
=
numpy
.
ones
((
2
,
3
),
dtype
=
config
.
floatX
)
yv
=
numpy
.
ones
((
3
,
4
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
4
,
5
),
dtype
=
config
.
floatX
)
*
5
yv
=
numpy
.
ones
((
3
,
4
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
4
,
5
),
dtype
=
config
.
floatX
)
*
5
res
=
fn
(
xv
,
yv
,
zv
)
assert
res
.
shape
==
(
2
,
5
)
assert
numpy
.
all
(
180.0
==
res
)
...
...
@@ -56,8 +55,8 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
f
=
f
-
T
.
grad
(
T
.
sum
(
f
),
y
)
fn
=
function
([
x
,
y
,
z
],
f
)
xv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
assert
numpy
.
all
(
11.0
==
fn
(
xv
,
yv
,
zv
))
def
test_grad_grad
(
self
):
...
...
@@ -69,8 +68,8 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
f
=
f
-
T
.
grad
(
T
.
sum
(
f
),
y
)
fn
=
function
([
x
,
y
,
z
],
f
)
xv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
assert
numpy
.
allclose
(
6.0
,
fn
(
xv
,
yv
,
zv
))
def
test_shared
(
self
):
...
...
@@ -83,8 +82,8 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
fn
=
function
([
x
,
y
,
z
],
f
)
xv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
# print function, function.__module__
# print fn.maker.fgraph.toposort()
assert
numpy
.
allclose
(
8.0
,
fn
(
xv
,
yv
,
zv
))
...
...
@@ -116,7 +115,7 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
out1
=
x
*
y
out2
=
y
*
z
op1
=
OpFromGraph
([
x
,
y
,
z
],
[
out1
,
out2
])
op1
=
OpFromGraph
([
x
,
y
,
z
],
[
out1
,
out2
])
results
=
op1
.
connection_pattern
(
None
)
expect_result
=
[[
True
,
False
],
[
True
,
True
],
...
...
@@ -139,7 +138,7 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
# Inner graph where some computation doesn't rely on explicit inputs
srng
=
RandomStreams
(
seed
=
234
)
rv_u
=
srng
.
uniform
((
2
,
2
))
rv_u
=
srng
.
uniform
((
2
,
2
))
x
,
y
=
T
.
matrices
(
'xy'
)
out1
=
x
+
rv_u
out2
=
y
+
3
...
...
@@ -155,14 +154,14 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
def
test_infer_shape
(
self
):
x
=
T
.
matrix
(
'x'
)
y
=
T
.
matrix
(
'y'
)
o1
=
x
+
y
o2
=
x
*
y
op_graph
=
OpFromGraph
([
x
,
y
],
[
o1
,
o2
])
o1
=
x
+
y
o2
=
x
*
y
op_graph
=
OpFromGraph
([
x
,
y
],
[
o1
,
o2
])
q
=
T
.
matrix
(
'q'
)
p
=
T
.
matrix
(
'p'
)
self
.
_compile_and_check
([
q
,
p
],
op_graph
(
q
,
p
),
[
numpy
.
ones
([
3
,
4
],
dtype
=
config
.
floatX
),
numpy
.
ones
([
3
,
4
],
dtype
=
config
.
floatX
)],
self
.
_compile_and_check
([
q
,
p
],
op_graph
(
q
,
p
),
[
numpy
.
ones
([
3
,
4
],
dtype
=
config
.
floatX
),
numpy
.
ones
([
3
,
4
],
dtype
=
config
.
floatX
)],
OpFromGraph
)
theano/compile/tests/test_debugmode.py
浏览文件 @
0b5dbed9
...
...
@@ -160,16 +160,16 @@ class WeirdBrokenOp(gof.Op):
if
self
.
behaviour
==
'times2'
:
behaviour
=
" Dz[m * Sz] = 2 * Da[m * Sa]; "
#out[0] = a * 2
#
out[0] = a * 2
elif
self
.
behaviour
==
'times2_inplace'
:
#out[0] = a
#out[0] *= 2
#
out[0] = a
#
out[0] *= 2
behaviour
=
" Dz[m * Sz] = 2 * Da[m * Sa]; "
elif
self
.
behaviour
==
'times1'
:
#out[0] = a * 1
#
out[0] = a * 1
behaviour
=
" Dz[m * Sz] = Da[m * Sa]; "
elif
self
.
behaviour
==
'times1_inplace'
:
#out[0] = a
#
out[0] = a
behaviour
=
""
else
:
raise
ValueError
(
self
.
behaviour
)
...
...
@@ -189,7 +189,7 @@ wb1 = WeirdBrokenOp('times1')
def
test_badthunkoutput
():
# Check if the c and python code is consistent.
# Check if the c and python code is consistent.
a
=
theano
.
tensor
.
dvector
()
b
=
theano
.
tensor
.
dvector
()
...
...
@@ -533,7 +533,7 @@ class Test_ViewMap(unittest.TestCase):
# pretending that it is aliased to both the outputs.
# This unfairly disables any destructive operations on the
# input, but guarantees correctness.
#custom_op.view_map = {0:[0], 1:[1]}
#
custom_op.view_map = {0:[0], 1:[1]}
# f([1,2,3,4],[5,6,7,8])
...
...
@@ -737,7 +737,7 @@ class Test_preallocated_output(unittest.TestCase):
check_preallocated_output
=
[
'c_contiguous'
])
f
=
theano
.
function
([
a
,
b
],
out
,
mode
=
mode
)
out_val
=
f
(
a_val
,
b_val
)
#
out_val = f(a_val, b_val)
# print 'out_val =', out_val
# print out_val.strides
...
...
@@ -769,7 +769,7 @@ class Test_preallocated_output(unittest.TestCase):
check_preallocated_output
=
[
'c_contiguous'
])
f
=
theano
.
function
([
a
,
b
],
out
,
mode
=
mode
)
out_val
=
f
(
a_val
,
b_val
)
#
out_val = f(a_val, b_val)
# print 'out_val =', out_val
# print out_val.strides
...
...
theano/compile/tests/test_function_module.py
浏览文件 @
0b5dbed9
差异被折叠。
点击展开。
theano/compile/tests/test_misc.py
浏览文件 @
0b5dbed9
import
numpy
,
theano
,
unittest
import
numpy
import
unittest
from
theano.compile.pfunc
import
pfunc
from
theano.compile.sharedvalue
import
shared
...
...
@@ -56,5 +57,7 @@ class TestNnet(unittest.TestCase):
# print 'Mean cost at epoch %s: %s' % (epoch, mean_cost)
self
.
assertTrue
(
abs
(
mean_cost
-
0.20588975452
)
<
1e-6
)
# Just call functions to make sure they do not crash.
out
=
nnet
.
compute_output
(
input
)
out
=
nnet
.
output_from_hidden
(
numpy
.
ones
(
10
))
# out = nnet.compute_output(input)
# out = nnet.output_from_hidden(numpy.ones(10))
nnet
.
compute_output
(
input
)
nnet
.
output_from_hidden
(
numpy
.
ones
(
10
))
theano/compile/tests/test_monitormode.py
浏览文件 @
0b5dbed9
...
...
@@ -75,7 +75,7 @@ def test_not_inplace():
x
=
theano
.
tensor
.
vector
(
'x'
)
mode
=
theano
.
compile
.
MonitorMode
(
post_func
=
detect_nan
)
#mode = mode.excluding('fusion', 'inplace')
#
mode = mode.excluding('fusion', 'inplace')
mode
=
mode
.
excluding
(
'local_elemwise_fusion'
,
'inplace_elemwise_optimizer'
)
o
=
theano
.
tensor
.
outer
(
x
,
x
)
...
...
theano/compile/tests/test_pfunc.py
浏览文件 @
0b5dbed9
...
...
@@ -712,7 +712,7 @@ class Test_aliasing_rules(unittest.TestCase):
pass
from
theano.sparse
import
enable_sparse
if
enable_sparse
==
Fal
se
:
if
not
enable_spar
se
:
raise
SkipTest
(
'Optional package sparse disabled'
)
from
theano
import
sparse
...
...
@@ -816,9 +816,9 @@ class Test_aliasing_rules(unittest.TestCase):
theano
.
In
(
m1
,
mutable
=
True
),
theano
.
In
(
m2
,
mutable
=
True
),
theano
.
In
(
m3
,
mutable
=
True
)],
(
theano
.
dot
((
x
*
2
),
m1
)
+
theano
.
dot
((
y
*
3
),
m2
)
+
theano
.
dot
((
z
*
4
),
m3
)))
(
theano
.
dot
((
x
*
2
),
m1
)
+
theano
.
dot
((
y
*
3
),
m2
)
+
theano
.
dot
((
z
*
4
),
m3
)))
# Compute bogus values
v
=
numpy
.
asarray
([
1
,
2
,
3
,
4
,
5
],
dtype
=
'float64'
)
...
...
theano/compile/tests/test_profiling.py
浏览文件 @
0b5dbed9
...
...
@@ -44,7 +44,7 @@ class Test_profiling(unittest.TestCase):
mode
=
m
)
inp
=
[
numpy
.
arange
(
1024
,
dtype
=
'float32'
)
+
1
for
i
in
range
(
len
(
x
))]
output
=
f
(
*
inp
)
f
(
*
inp
)
buf
=
StringIO
()
f
.
profile
.
summary
(
buf
)
...
...
@@ -72,7 +72,6 @@ class Test_profiling(unittest.TestCase):
theano
.
config
.
profile_memory
=
config2
theano
.
config
.
profiling
.
min_peak_memory
=
config3
def
test_ifelse
(
self
):
config1
=
theano
.
config
.
profile
config2
=
theano
.
config
.
profile_memory
...
...
@@ -101,7 +100,8 @@ class Test_profiling(unittest.TestCase):
big_mat1
=
10
big_mat2
=
11
out
=
f_ifelse
(
val1
,
val2
,
big_mat1
,
big_mat2
)
# out = f_ifelse(val1, val2, big_mat1, big_mat2)
f_ifelse
(
val1
,
val2
,
big_mat1
,
big_mat2
)
finally
:
theano
.
config
.
profile
=
config1
...
...
theano/compile/tests/test_shared.py
浏览文件 @
0b5dbed9
...
...
@@ -31,8 +31,7 @@ class Test_SharedVariable(unittest.TestCase):
b
=
shared
(
numpy
.
random
.
rand
(
4
,
5
))
assert
b
.
type
==
TensorType
(
'float64'
,
broadcastable
=
[
False
,
False
])
b
=
shared
(
numpy
.
random
.
rand
(
5
,
1
,
2
))
assert
b
.
type
==
TensorType
(
'float64'
,
broadcastable
=
[
False
,
False
,
False
])
assert
b
.
type
==
TensorType
(
'float64'
,
broadcastable
=
[
False
,
False
,
False
])
assert
shared
([])
.
type
==
generic
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论