Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d5944c96
提交
d5944c96
authored
7月 18, 2016
作者:
nke001
提交者:
abergeron
7月 18, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ccw4057 (#4592)
* flake 8 changes * flake 8 changes * add missing imports * code cleanup * code clean up * flake 8 changes * code cleanup * code cleanup * code cleanup * code cleanup * add missing import
上级
74b4c807
全部展开
显示空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
48 行增加
和
56 行删除
+48
-56
__init__.py
theano/tensor/nnet/tests/__init__.py
+1
-0
speed_test_conv.py
theano/tensor/nnet/tests/speed_test_conv.py
+0
-0
test_conv.py
theano/tensor/nnet/tests/test_conv.py
+0
-0
test_conv3d.py
theano/tensor/nnet/tests/test_conv3d.py
+0
-0
test_conv3d2d.py
theano/tensor/nnet/tests/test_conv3d2d.py
+15
-15
test_neighbours.py
theano/tensor/nnet/tests/test_neighbours.py
+0
-0
test_nnet.py
theano/tensor/nnet/tests/test_nnet.py
+0
-0
test_sigm.py
theano/tensor/nnet/tests/test_sigm.py
+32
-33
test_flake8.py
theano/tests/test_flake8.py
+0
-8
没有找到文件。
theano/tensor/nnet/tests/__init__.py
浏览文件 @
d5944c96
from
__future__
import
absolute_import
,
print_function
,
division
theano/tensor/nnet/tests/speed_test_conv.py
浏览文件 @
d5944c96
差异被折叠。
点击展开。
theano/tensor/nnet/tests/test_conv.py
浏览文件 @
d5944c96
差异被折叠。
点击展开。
theano/tensor/nnet/tests/test_conv3d.py
浏览文件 @
d5944c96
差异被折叠。
点击展开。
theano/tensor/nnet/tests/test_conv3d2d.py
浏览文件 @
d5944c96
...
...
@@ -11,7 +11,7 @@ from six.moves import xrange
import
theano
from
theano.gof.opt
import
check_stack_trace
from
theano.tensor.nnet.conv3d2d
import
*
from
theano.tensor.nnet.conv3d2d
import
conv3d
,
get_diagonal_subtensor_view
,
DiagonalSubtensor
,
IncDiagonalSubtensor
import
theano.tests.unittest_tools
as
utt
...
...
@@ -57,11 +57,11 @@ def pyconv3d(signals, filters):
Ns
,
Ts
,
C
,
Hs
,
Ws
=
signals
.
shape
Nf
,
Tf
,
C
,
Hf
,
Wf
=
filters
.
shape
Tf2
=
Tf
//
2
Hf2
=
Hf
//
2
Wf2
=
Wf
//
2
Tf2
=
Tf
//
2
Hf2
=
Hf
//
2
Wf2
=
Wf
//
2
rval
=
numpy
.
zeros
((
Ns
,
Ts
-
Tf
+
1
,
Nf
,
Hs
-
Hf
+
1
,
Ws
-
Wf
+
1
))
rval
=
numpy
.
zeros
((
Ns
,
Ts
-
Tf
+
1
,
Nf
,
Hs
-
Hf
+
1
,
Ws
-
Wf
+
1
))
for
ns
in
xrange
(
Ns
):
for
nf
in
xrange
(
Nf
):
for
c
in
xrange
(
C
):
...
...
@@ -71,7 +71,7 @@ def pyconv3d(signals, filters):
o_i
=
ndimage
.
convolve
(
s_i
,
f_i
,
mode
=
'constant'
,
cval
=
1
)
o_i_sh0
=
o_i
.
shape
[
0
]
# print s_i.shape, f_i.shape, r_i.shape, o_i.shape
r_i
+=
o_i
[
Tf2
:
o_i_sh0
-
Tf2
,
Hf2
:
-
Hf2
,
Wf2
:
-
Wf2
]
r_i
+=
o_i
[
Tf2
:
o_i_sh0
-
Tf2
,
Hf2
:
-
Hf2
,
Wf2
:
-
Wf2
]
return
rval
...
...
@@ -85,10 +85,10 @@ def test_conv3d(mode=mode_without_gpu, shared=theano.tensor._shared):
raise
SkipTest
(
"conv3d2d tests need SciPy"
)
Ns
,
Ts
,
C
,
Hs
,
Ws
=
3
,
10
,
3
,
32
,
32
Nf
,
Tf
,
C
,
Hf
,
Wf
=
32
,
5
,
3
,
5
,
5
Nf
,
Tf
,
C
,
Hf
,
Wf
=
32
,
5
,
3
,
5
,
5
signals
=
numpy
.
arange
(
Ns
*
Ts
*
C
*
Hs
*
Ws
)
.
reshape
(
Ns
,
Ts
,
C
,
Hs
,
Ws
)
.
astype
(
'float32'
)
filters
=
numpy
.
arange
(
Nf
*
Tf
*
C
*
Hf
*
Wf
)
.
reshape
(
Nf
,
Tf
,
C
,
Hf
,
Wf
)
.
astype
(
'float32'
)
signals
=
numpy
.
arange
(
Ns
*
Ts
*
C
*
Hs
*
Ws
)
.
reshape
(
Ns
,
Ts
,
C
,
Hs
,
Ws
)
.
astype
(
'float32'
)
filters
=
numpy
.
arange
(
Nf
*
Tf
*
C
*
Hf
*
Wf
)
.
reshape
(
Nf
,
Tf
,
C
,
Hf
,
Wf
)
.
astype
(
'float32'
)
t0
=
time
.
time
()
pyres
=
pyconv3d
(
signals
,
filters
)
...
...
@@ -96,7 +96,7 @@ def test_conv3d(mode=mode_without_gpu, shared=theano.tensor._shared):
s_signals
=
shared
(
signals
)
s_filters
=
shared
(
filters
)
s_output
=
shared
(
signals
*
0
)
s_output
=
shared
(
signals
*
0
)
out
=
conv3d
(
s_signals
,
s_filters
,
signals_shape
=
signals
.
shape
,
...
...
@@ -130,12 +130,12 @@ def test_conv3d(mode=mode_without_gpu, shared=theano.tensor._shared):
filters
=
numpy
.
random
.
rand
(
Nf
,
Tf
,
C
,
Hf
,
Wf
)
.
astype
(
'float32'
)
utt
.
verify_grad
(
conv3d
,
[
signals
,
filters
],
eps
=
1e-1
,
mode
=
mode
)
#
##
Additional Test that covers the case of patched implementation for filter with Tf=1
# Additional Test that covers the case of patched implementation for filter with Tf=1
Ns
,
Ts
,
C
,
Hs
,
Ws
=
3
,
10
,
3
,
32
,
32
Nf
,
Tf
,
C
,
Hf
,
Wf
=
32
,
1
,
3
,
5
,
5
Nf
,
Tf
,
C
,
Hf
,
Wf
=
32
,
1
,
3
,
5
,
5
signals
=
numpy
.
arange
(
Ns
*
Ts
*
C
*
Hs
*
Ws
)
.
reshape
(
Ns
,
Ts
,
C
,
Hs
,
Ws
)
.
astype
(
'float32'
)
filters
=
numpy
.
arange
(
Nf
*
Tf
*
C
*
Hf
*
Wf
)
.
reshape
(
Nf
,
Tf
,
C
,
Hf
,
Wf
)
.
astype
(
'float32'
)
signals
=
numpy
.
arange
(
Ns
*
Ts
*
C
*
Hs
*
Ws
)
.
reshape
(
Ns
,
Ts
,
C
,
Hs
,
Ws
)
.
astype
(
'float32'
)
filters
=
numpy
.
arange
(
Nf
*
Tf
*
C
*
Hf
*
Wf
)
.
reshape
(
Nf
,
Tf
,
C
,
Hf
,
Wf
)
.
astype
(
'float32'
)
t0
=
time
.
time
()
pyres
=
pyconv3d
(
signals
,
filters
)
...
...
@@ -143,7 +143,7 @@ def test_conv3d(mode=mode_without_gpu, shared=theano.tensor._shared):
s_signals
=
shared
(
signals
)
s_filters
=
shared
(
filters
)
s_output
=
shared
(
signals
*
0
)
s_output
=
shared
(
signals
*
0
)
out
=
conv3d
(
s_signals
,
s_filters
,
signals_shape
=
signals
.
shape
,
...
...
theano/tensor/nnet/tests/test_neighbours.py
浏览文件 @
d5944c96
差异被折叠。
点击展开。
theano/tensor/nnet/tests/test_nnet.py
浏览文件 @
d5944c96
差异被折叠。
点击展开。
theano/tensor/nnet/tests/test_sigm.py
浏览文件 @
d5944c96
...
...
@@ -16,7 +16,7 @@ from theano.tensor.nnet.sigm import (
compute_mul
,
is_1pexp
,
parse_mul_tree
,
perform_sigm_times_exp
,
register_local_1msigmoid
,
simplify_mul
,
)
from
theano.tensor.tests.test_basic
import
(
makeBroadcastTester
,
rand
,
from
theano.tensor.tests.test_basic
import
(
makeBroadcastTester
,
check_floatX
,
upcast_int8_nfunc
,
_good_broadcast_unary_normal_no_complex
)
...
...
@@ -45,7 +45,7 @@ UltraFastSigmoidTester = makeBroadcastTester(
good
=
_good_broadcast_unary_normal_no_complex
,
# grad=_grad_broadcast_unary_normal,
name
=
'UltraFastSigmoidTester'
,
# This is an approx of the sigmoid. That is why we raise eps
# This is an approx of the sigmoid. That is why we raise eps
eps
=
5e-2
)
HardSigmoidTester
=
makeBroadcastTester
(
...
...
@@ -55,7 +55,7 @@ HardSigmoidTester = makeBroadcastTester(
good
=
_good_broadcast_unary_normal_no_complex
,
# grad=_grad_broadcast_unary_normal,
name
=
'HardSigmoidTester'
,
# This is an approx of the sigmoid. That is why we raise eps
# This is an approx of the sigmoid. That is why we raise eps
eps
=
1e-1
)
...
...
@@ -146,20 +146,20 @@ class T_sigmoid_opts(unittest.TestCase):
# todo: solve issue #4589 first
# assert check_stack_trace(
# f, ops_to_check=[sigmoid, theano.tensor.inplace.neg_inplace])
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
sigmoid
,
theano
.
tensor
.
inplace
.
neg_inplace
]
assert
([
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
sigmoid
,
theano
.
tensor
.
inplace
.
neg_inplace
])
f
(
data
)
f
=
theano
.
function
([
x
],
T
.
fill
(
x
,
-
1.0
)
/
(
1
-
T
.
exp
(
-
x
)),
mode
=
m
)
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
!=
[
sigmoid
,
theano
.
tensor
.
inplace
.
neg_inplace
]
assert
(
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
!=
[
sigmoid
,
theano
.
tensor
.
inplace
.
neg_inplace
]
)
f
(
data
)
f
=
theano
.
function
([
x
],
T
.
fill
(
x
,
-
1.0
)
/
(
2
+
T
.
exp
(
-
x
)),
mode
=
m
)
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
!=
[
sigmoid
,
theano
.
tensor
.
inplace
.
neg_inplace
]
assert
(
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
!=
[
sigmoid
,
theano
.
tensor
.
inplace
.
neg_inplace
]
)
f
(
data
)
f
=
theano
.
function
([
x
],
T
.
fill
(
x
,
-
1.1
)
/
(
1
+
T
.
exp
(
-
x
)),
mode
=
m
)
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
!=
[
sigmoid
,
theano
.
tensor
.
inplace
.
neg_inplace
]
assert
(
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
!=
[
sigmoid
,
theano
.
tensor
.
inplace
.
neg_inplace
]
)
f
(
data
)
# tests double inv_1_plus_exp with neg
...
...
@@ -170,33 +170,33 @@ class T_sigmoid_opts(unittest.TestCase):
((
1
+
T
.
exp
(
x
))
*
(
1
+
T
.
exp
(
-
x
))),
mode
=
m
)
# todo: solve issue #4589 first
# assert check_stack_trace(f, ops_to_check=[sigmoid, T.mul])
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
sigmoid
,
T
.
mul
]
assert
(
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
sigmoid
,
T
.
mul
]
)
f
(
data
)
f
=
theano
.
function
([
x
],
(
T
.
fill
(
x
,
-
1.1
)
*
T
.
exp
(
x
))
/
((
1
+
T
.
exp
(
x
))
*
(
1
+
T
.
exp
(
-
x
))),
mode
=
m
)
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
!=
[
sigmoid
,
T
.
mul
,
theano
.
tensor
.
inplace
.
neg_inplace
]
assert
(
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
!=
[
sigmoid
,
T
.
mul
,
theano
.
tensor
.
inplace
.
neg_inplace
]
)
f
(
data
)
f
=
theano
.
function
([
x
],
(
T
.
fill
(
x
,
-
1.0
)
*
T
.
exp
(
x
))
/
((
2
+
T
.
exp
(
x
))
*
(
1
+
T
.
exp
(
-
x
))),
mode
=
m
)
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
!=
[
sigmoid
,
T
.
mul
,
theano
.
tensor
.
inplace
.
neg_inplace
]
assert
(
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
!=
[
sigmoid
,
T
.
mul
,
theano
.
tensor
.
inplace
.
neg_inplace
]
)
f
(
data
)
f
=
theano
.
function
([
x
],
(
T
.
fill
(
x
,
-
1.0
)
*
T
.
exp
(
x
))
/
((
1
+
T
.
exp
(
x
))
*
(
2
+
T
.
exp
(
-
x
))),
mode
=
m
)
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
!=
[
sigmoid
,
T
.
mul
,
theano
.
tensor
.
inplace
.
neg_inplace
]
assert
(
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
!=
[
sigmoid
,
T
.
mul
,
theano
.
tensor
.
inplace
.
neg_inplace
]
)
f
(
data
)
f
=
theano
.
function
([
x
],
(
T
.
fill
(
x
,
-
1.0
)
*
T
.
exp
(
x
))
/
((
1
+
T
.
exp
(
x
))
*
(
1
+
T
.
exp
(
x
))),
mode
=
m
)
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
!=
[
sigmoid
,
T
.
mul
,
theano
.
tensor
.
inplace
.
neg_inplace
]
assert
(
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
!=
[
sigmoid
,
T
.
mul
,
theano
.
tensor
.
inplace
.
neg_inplace
]
)
f
(
data
)
f
=
theano
.
function
([
x
],
(
T
.
fill
(
x
,
-
1.0
)
*
T
.
exp
(
x
))
/
((
1
+
T
.
exp
(
x
))
*
(
2
+
T
.
exp
(
-
x
))),
mode
=
m
)
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
!=
[
sigmoid
,
T
.
mul
,
theano
.
tensor
.
inplace
.
neg_inplace
]
assert
(
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
!=
[
sigmoid
,
T
.
mul
,
theano
.
tensor
.
inplace
.
neg_inplace
]
)
f
(
data
)
finally
:
...
...
@@ -219,8 +219,8 @@ class T_sigmoid_opts(unittest.TestCase):
# tests inv_1_plus_exp
f
=
theano
.
function
([
x
],
1
-
T
.
fill
(
x
,
1.0
)
/
(
1
+
T
.
exp
(
-
x
)),
mode
=
m
)
assert
check_stack_trace
(
f
,
ops_to_check
=
[
tensor
.
neg
,
sigmoid_inplace
])
assert
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
tensor
.
neg
,
sigmoid_inplace
]
assert
(
[
node
.
op
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
==
[
tensor
.
neg
,
sigmoid_inplace
]
)
def
test_local_sigm_times_exp
(
self
):
"""
...
...
@@ -249,8 +249,7 @@ class T_sigmoid_opts(unittest.TestCase):
f
=
theano
.
function
(
[
x
,
y
],
(
sigmoid
(
x
)
*
sigmoid
(
-
y
)
*
-
tensor
.
exp
(
-
x
)
*
tensor
.
exp
(
x
*
y
)
*
tensor
.
exp
(
y
)),
mode
=
m
)
tensor
.
exp
(
x
*
y
)
*
tensor
.
exp
(
y
)),
mode
=
m
)
match
(
f
,
[
sigmoid
,
tensor
.
mul
,
tensor
.
neg
,
tensor
.
exp
,
sigmoid
,
tensor
.
mul
])
# assert check_stack_trace(f, ops_to_check=[sigmoid, tensor.mul,
...
...
@@ -286,11 +285,11 @@ class T_sigmoid_opts(unittest.TestCase):
-
x
*
sigmoid
(
-
x
)
*
(
y
*
(
-
1
*
z
)))
ok
(
-
sigmoid
(
-
x
)
*
(
exp
(
y
)
*
(
-
exp
(
-
z
)
*
3
*
-
exp
(
x
))
*
(
y
*
2
*
(
-
sigmoid
(
-
y
)
*
(
z
+
t
)
*
exp
(
z
))
*
sigmoid
(
z
)))
*
-
sigmoid
(
x
),
(
y
*
2
*
(
-
sigmoid
(
-
y
)
*
(
z
+
t
)
*
exp
(
z
))
*
sigmoid
(
z
)))
*
-
sigmoid
(
x
),
sigmoid
(
x
)
*
(
-
sigmoid
(
y
)
*
(
-
sigmoid
(
-
z
)
*
3
)
*
(
y
*
2
*
((
z
+
t
)
*
exp
(
z
))))
*
-
sigmoid
(
x
))
(
-
sigmoid
(
x
)
))
ok
(
exp
(
-
x
)
*
-
exp
(
-
x
)
*
(
-
sigmoid
(
x
)
*
-
sigmoid
(
x
)),
-
sigmoid
(
-
x
)
*
sigmoid
(
-
x
))
ok
(
-
exp
(
x
)
*
-
sigmoid
(
-
x
)
*
-
exp
(
-
x
),
...
...
@@ -333,7 +332,7 @@ class T_sigmoid_opts(unittest.TestCase):
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
topo
[
0
]
.
op
==
ultra_fast_sigmoid
assert
len
(
topo
)
==
1
ux_v
=
f
([[
-
50
,
-
10
,
-
4
,
-
1
,
0
,
1
,
4
,
10
,
50
]])
f
([[
-
50
,
-
10
,
-
4
,
-
1
,
0
,
1
,
4
,
10
,
50
]])
def
test_local_hard_sigmoid
(
self
):
x
=
tensor
.
matrix
(
'x'
)
...
...
@@ -350,7 +349,7 @@ class T_sigmoid_opts(unittest.TestCase):
f
=
theano
.
function
([
x
],
s
,
mode
=
mode
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
not
any
([
n
.
op
==
sigmoid
for
n
in
topo
])
ux_v
=
f
([[
-
50
,
-
10
,
-
4
,
-
1
,
0
,
1
,
4
,
10
,
50
]])
f
([[
-
50
,
-
10
,
-
4
,
-
1
,
0
,
1
,
4
,
10
,
50
]])
mode2
=
mode
.
excluding
(
'fusion'
)
.
excluding
(
'inplace'
)
f2
=
theano
.
function
([
x
],
s
,
mode
=
mode2
)
...
...
@@ -416,7 +415,7 @@ class T_softplus_opts(unittest.TestCase):
out
=
T
.
log
(
1
-
sigmoid
(
x
)
.
reshape
([
x
.
size
]))
f
=
theano
.
function
([
x
],
out
,
mode
=
self
.
m
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
#assert len(topo) == 3
#
assert len(topo) == 3
assert
any
(
isinstance
(
node
.
op
,
T
.
Reshape
)
for
node
in
topo
)
assert
any
(
isinstance
(
getattr
(
node
.
op
,
'scalar_op'
,
None
),
theano
.
tensor
.
nnet
.
sigm
.
ScalarSoftplus
)
...
...
theano/tests/test_flake8.py
浏览文件 @
d5944c96
...
...
@@ -72,14 +72,6 @@ whitelist_flake8 = [
"tensor/tests/test_blas_scipy.py"
,
"tensor/tests/test_mpi.py"
,
"tensor/nnet/__init__.py"
,
"tensor/nnet/tests/__init__.py"
,
"tensor/nnet/tests/test_conv.py"
,
"tensor/nnet/tests/test_neighbours.py"
,
"tensor/nnet/tests/test_nnet.py"
,
"tensor/nnet/tests/test_conv3d2d.py"
,
"tensor/nnet/tests/test_conv3d.py"
,
"tensor/nnet/tests/speed_test_conv.py"
,
"tensor/nnet/tests/test_sigm.py"
,
"tensor/signal/__init__.py"
,
"tensor/signal/tests/__init__.py"
,
"scalar/__init__.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论