Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3089deda
提交
3089deda
authored
3月 28, 2015
作者:
Bart van Merrienboer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix E261: at least two spaces before inline comment
上级
b34bc31d
隐藏空白字符变更
内嵌
并排
正在显示
47 个修改的文件
包含
390 行增加
和
390 行删除
+390
-390
python2x.py
theano/compat/python2x.py
+1
-1
debugmode.py
theano/compile/debugmode.py
+6
-6
function_module.py
theano/compile/function_module.py
+4
-4
profilemode.py
theano/compile/profilemode.py
+1
-1
test_function_module.py
theano/compile/tests/test_function_module.py
+68
-68
callcache.py
theano/gof/callcache.py
+1
-1
destroyhandler.py
theano/gof/destroyhandler.py
+5
-5
fg.py
theano/gof/fg.py
+1
-1
link.py
theano/gof/link.py
+1
-1
test_graph.py
theano/gof/tests/test_graph.py
+4
-4
test_opt.py
theano/gof/tests/test_opt.py
+5
-5
type.py
theano/gof/type.py
+2
-2
unify.py
theano/gof/unify.py
+5
-5
check_duplicate_key.py
theano/misc/check_duplicate_key.py
+4
-4
cudamat_utils.py
theano/misc/cudamat_utils.py
+3
-3
gnumpy_utils.py
theano/misc/gnumpy_utils.py
+3
-3
check_whitespace.py
theano/misc/hooks/check_whitespace.py
+3
-3
pycuda_utils.py
theano/misc/pycuda_utils.py
+1
-1
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+2
-2
elemwise.py
theano/sandbox/cuda/elemwise.py
+5
-5
test_basic_ops.py
theano/sandbox/cuda/tests/test_basic_ops.py
+37
-37
test_bench_loopfusion.py
theano/sandbox/cuda/tests/test_bench_loopfusion.py
+8
-8
test_conv_cuda_ndarray.py
theano/sandbox/cuda/tests/test_conv_cuda_ndarray.py
+53
-53
var.py
theano/sandbox/cuda/var.py
+2
-2
debug.py
theano/sandbox/debug.py
+1
-1
basic_ops.py
theano/sandbox/gpuarray/basic_ops.py
+1
-1
elemwise.py
theano/sandbox/gpuarray/elemwise.py
+1
-1
test_conv_cuda_ndarray.py
theano/sandbox/gpuarray/tests/test_conv_cuda_ndarray.py
+52
-52
test_elemwise.py
theano/sandbox/gpuarray/tests/test_elemwise.py
+27
-27
ops.py
theano/sandbox/linalg/ops.py
+2
-2
symbolic_module.py
theano/sandbox/symbolic_module.py
+6
-6
test_theano_object.py
theano/sandbox/test_theano_object.py
+7
-7
basic.py
theano/scalar/basic.py
+1
-1
scan_op.py
theano/scan_module/scan_op.py
+1
-1
scan_opt.py
theano/scan_module/scan_opt.py
+2
-2
test_sp.py
theano/sparse/sandbox/test_sp.py
+6
-6
elemwise_cgen.py
theano/tensor/elemwise_cgen.py
+3
-3
speed_test_conv.py
theano/tensor/nnet/tests/speed_test_conv.py
+16
-16
test_nnet.py
theano/tensor/nnet/tests/test_nnet.py
+1
-1
test_downsample.py
theano/tensor/signal/tests/test_downsample.py
+2
-2
mlp_test.py
theano/tensor/tests/mlp_test.py
+1
-1
test_blas_scipy.py
theano/tensor/tests/test_blas_scipy.py
+3
-3
test_mpi.py
theano/tensor/tests/test_mpi.py
+2
-2
test_opt.py
theano/tensor/tests/test_opt.py
+8
-8
test_shared_randomstreams.py
theano/tensor/tests/test_shared_randomstreams.py
+10
-10
test_sharedvar.py
theano/tensor/tests/test_sharedvar.py
+7
-7
test_tutorial.py
theano/tests/test_tutorial.py
+5
-5
没有找到文件。
theano/compat/python2x.py
浏览文件 @
3089deda
...
@@ -405,7 +405,7 @@ if sys.version_info[:2] < (2, 7):
...
@@ -405,7 +405,7 @@ if sys.version_info[:2] < (2, 7):
for
elem
,
count
in
iterable
.
iteritems
():
for
elem
,
count
in
iterable
.
iteritems
():
self
[
elem
]
=
self_get
(
elem
,
0
)
+
count
self
[
elem
]
=
self_get
(
elem
,
0
)
+
count
else
:
else
:
dict
.
update
(
self
,
iterable
)
# fast path when counter is empty
dict
.
update
(
self
,
iterable
)
# fast path when counter is empty
else
:
else
:
self_get
=
self
.
get
self_get
=
self
.
get
for
elem
in
iterable
:
for
elem
in
iterable
:
...
...
theano/compile/debugmode.py
浏览文件 @
3089deda
...
@@ -326,7 +326,7 @@ class BadDestroyMap(DebugModeError):
...
@@ -326,7 +326,7 @@ class BadDestroyMap(DebugModeError):
wasn't in the destroy_map"""
wasn't in the destroy_map"""
def
__init__
(
self
,
node
,
idx
,
old_val
,
new_val
,
perform
):
def
__init__
(
self
,
node
,
idx
,
old_val
,
new_val
,
perform
):
#super(BadDestroyMap, self).__init__()
#super(BadDestroyMap, self).__init__()
DebugModeError
.
__init__
(
self
)
#
to be compatible with python2.4
DebugModeError
.
__init__
(
self
)
#
to be compatible with python2.4
self
.
node
=
node
self
.
node
=
node
self
.
idx
=
idx
self
.
idx
=
idx
self
.
old_val
=
old_val
self
.
old_val
=
old_val
...
@@ -794,7 +794,7 @@ def _check_inputs(node, storage_map, r_vals, dr_vals, active_nodes,
...
@@ -794,7 +794,7 @@ def _check_inputs(node, storage_map, r_vals, dr_vals, active_nodes,
# bad: there should only be one active node that destroys any variable
# bad: there should only be one active node that destroys any variable
raise
Exception
(
'failure in topological ordering'
)
raise
Exception
(
'failure in topological ordering'
)
if
clobber_dr_vals
:
if
clobber_dr_vals
:
dr_vals
[
r
]
=
(
storage_map
[
r
][
0
],
node
)
#
no copy, this is the last use of this variable
dr_vals
[
r
]
=
(
storage_map
[
r
][
0
],
node
)
#
no copy, this is the last use of this variable
# make sure that dr_vals[r] doens't get used again
# make sure that dr_vals[r] doens't get used again
storage_map
[
r
][
0
]
=
data_destroyed
storage_map
[
r
][
0
]
=
data_destroyed
else
:
else
:
...
@@ -887,7 +887,7 @@ def _check_strides_match(a, b, warn_err, op):
...
@@ -887,7 +887,7 @@ def _check_strides_match(a, b, warn_err, op):
try
:
try
:
strides_eq
=
a
.
strides
==
b
.
strides
strides_eq
=
a
.
strides
==
b
.
strides
except
Exception
:
except
Exception
:
return
# no strides
return
# no strides
if
not
strides_eq
:
if
not
strides_eq
:
e
=
TypeError
(
'Stride mismatch'
,
(
a
.
shape
,
b
.
shape
,
a
.
strides
,
e
=
TypeError
(
'Stride mismatch'
,
(
a
.
shape
,
b
.
shape
,
a
.
strides
,
...
@@ -1643,7 +1643,7 @@ class _Linker(gof.link.LocalLinker):
...
@@ -1643,7 +1643,7 @@ class _Linker(gof.link.LocalLinker):
order_outputs
.
reverse
()
order_outputs
.
reverse
()
order
=
graph
.
io_toposort
(
fgraph
.
inputs
,
order_outputs
)
order
=
graph
.
io_toposort
(
fgraph
.
inputs
,
order_outputs
)
active_order
=
self
.
schedule
(
fgraph
)
# an ordering of just the active nodes
active_order
=
self
.
schedule
(
fgraph
)
# an ordering of just the active nodes
active_order_set
=
set
(
active_order
)
active_order_set
=
set
(
active_order
)
# Disable no_recycling, in order to be able to use
# Disable no_recycling, in order to be able to use
...
@@ -1999,7 +1999,7 @@ class _Linker(gof.link.LocalLinker):
...
@@ -1999,7 +1999,7 @@ class _Linker(gof.link.LocalLinker):
raise
InvalidValueError
(
r
,
storage_map
[
r
][
0
],
hint
=
'c output'
)
raise
InvalidValueError
(
r
,
storage_map
[
r
][
0
],
hint
=
'c output'
)
if
thunk_py
:
if
thunk_py
:
assert
r
in
r_vals
#
because we put it in during the thunk_py branch
assert
r
in
r_vals
#
because we put it in during the thunk_py branch
# check for stride correctness (may raise exception)
# check for stride correctness (may raise exception)
_check_strides_match
(
r_vals
[
r
],
_check_strides_match
(
r_vals
[
r
],
storage_map
[
r
][
0
],
storage_map
[
r
][
0
],
...
@@ -2032,7 +2032,7 @@ class _Linker(gof.link.LocalLinker):
...
@@ -2032,7 +2032,7 @@ class _Linker(gof.link.LocalLinker):
#print >> sys.stderr, i, "DEBUGMODE storing reference output %x" % id(storage_map[r][0])
#print >> sys.stderr, i, "DEBUGMODE storing reference output %x" % id(storage_map[r][0])
# retrieve each output from the storage_map
# retrieve each output from the storage_map
r_vals
[
r
]
=
storage_map
[
r
][
0
]
r_vals
[
r
]
=
storage_map
[
r
][
0
]
storage_map
[
r
][
0
]
=
None
#
clear the storage_map for the thunk_c
storage_map
[
r
][
0
]
=
None
#
clear the storage_map for the thunk_c
if
self
.
maker
.
mode
.
check_preallocated_output
:
if
self
.
maker
.
mode
.
check_preallocated_output
:
prealloc_modes
=
\
prealloc_modes
=
\
...
...
theano/compile/function_module.py
浏览文件 @
3089deda
...
@@ -176,7 +176,7 @@ class AliasedMemoryError(Exception):
...
@@ -176,7 +176,7 @@ class AliasedMemoryError(Exception):
###
###
DUPLICATE
=
[
'DUPLICATE'
]
# unique id object used as a placeholder for duplicate entries
DUPLICATE
=
[
'DUPLICATE'
]
# unique id object used as a placeholder for duplicate entries
class
Function
(
object
):
class
Function
(
object
):
"""
"""
Type of the functions returned by theano.function or theano.FunctionMaker.create.
Type of the functions returned by theano.function or theano.FunctionMaker.create.
...
@@ -320,7 +320,7 @@ class Function(object):
...
@@ -320,7 +320,7 @@ class Function(object):
# Initialize the storage
# Initialize the storage
# this loop works by modifying the elements (as variable c) of self.input_storage inplace.
# this loop works by modifying the elements (as variable c) of self.input_storage inplace.
for
i
,
((
input
,
indices
,
sinputs
),
(
required
,
refeed
,
value
))
in
enumerate
(
zip
(
self
.
indices
,
defaults
)):
for
i
,
((
input
,
indices
,
sinputs
),
(
required
,
refeed
,
value
))
in
enumerate
(
zip
(
self
.
indices
,
defaults
)):
if
indices
is
None
:
# this is true iff input is not a SymbolicInputKit
if
indices
is
None
:
# this is true iff input is not a SymbolicInputKit
c
=
containers
[
0
]
#containers is being used as a stack. Here we pop off the next one.
c
=
containers
[
0
]
#containers is being used as a stack. Here we pop off the next one.
c
.
strict
=
getattr
(
input
,
'strict'
,
False
)
c
.
strict
=
getattr
(
input
,
'strict'
,
False
)
c
.
allow_downcast
=
getattr
(
input
,
'allow_downcast'
,
None
)
c
.
allow_downcast
=
getattr
(
input
,
'allow_downcast'
,
None
)
...
@@ -338,7 +338,7 @@ class Function(object):
...
@@ -338,7 +338,7 @@ class Function(object):
c
.
value
=
value
c
.
value
=
value
c
.
required
=
required
c
.
required
=
required
c
.
implicit
=
input
.
implicit
c
.
implicit
=
input
.
implicit
c
.
provided
=
0
# this is a count of how many times the input has been provided (reinitialized to 0 on __call__)
c
.
provided
=
0
# this is a count of how many times the input has been provided (reinitialized to 0 on __call__)
finder
[
i
]
=
c
finder
[
i
]
=
c
finder
[
input
.
variable
]
=
c
finder
[
input
.
variable
]
=
c
if
input
.
name
not
in
finder
:
if
input
.
name
not
in
finder
:
...
@@ -726,7 +726,7 @@ def _pickle_Function(f):
...
@@ -726,7 +726,7 @@ def _pickle_Function(f):
# HACK to detect aliased storage.
# HACK to detect aliased storage.
# This is here because aliased relationships are not [currently] preserved across the pickle operation
# This is here because aliased relationships are not [currently] preserved across the pickle operation
if
not
(
f
.
pickle_aliased_memory_strategy
==
'ignore'
):
if
not
(
f
.
pickle_aliased_memory_strategy
==
'ignore'
):
all_data
=
input_storage
+
inputs_data
# addition here means list append
all_data
=
input_storage
+
inputs_data
# addition here means list append
for
i
,
d_i
in
enumerate
(
all_data
):
for
i
,
d_i
in
enumerate
(
all_data
):
for
j
,
d_j
in
enumerate
(
all_data
):
for
j
,
d_j
in
enumerate
(
all_data
):
if
(
i
<
j
)
and
isinstance
(
d_i
,
numpy
.
ndarray
)
and
isinstance
(
d_j
,
numpy
.
ndarray
):
if
(
i
<
j
)
and
isinstance
(
d_i
,
numpy
.
ndarray
)
and
isinstance
(
d_j
,
numpy
.
ndarray
):
...
...
theano/compile/profilemode.py
浏览文件 @
3089deda
...
@@ -402,7 +402,7 @@ class ProfileMode(Mode):
...
@@ -402,7 +402,7 @@ class ProfileMode(Mode):
sop_time
=
{}
sop_time
=
{}
sop_call
=
{}
sop_call
=
{}
sop_op
=
{}
sop_op
=
{}
sop_cimpl
=
{}
#
map each op class to Bool. True iff all applies were done in c.
sop_cimpl
=
{}
#
map each op class to Bool. True iff all applies were done in c.
for
a
,
t
in
op_time
.
items
():
for
a
,
t
in
op_time
.
items
():
typ
=
type
(
a
)
typ
=
type
(
a
)
sop_time
.
setdefault
(
typ
,
0
)
sop_time
.
setdefault
(
typ
,
0
)
...
...
theano/compile/tests/test_function_module.py
浏览文件 @
3089deda
...
@@ -36,7 +36,7 @@ def checkfor(testcase, fn, E):
...
@@ -36,7 +36,7 @@ def checkfor(testcase, fn, E):
class
T_function
(
unittest
.
TestCase
):
class
T_function
(
unittest
.
TestCase
):
def
test_none
(
self
):
def
test_none
(
self
):
fn
=
function
([],
None
)
#
ok
fn
=
function
([],
None
)
#
ok
rval
=
fn
()
rval
=
fn
()
if
rval
==
[]:
if
rval
==
[]:
raise
KnownFailureTest
(
'See #254: Using None as function output leads to [] return value'
)
raise
KnownFailureTest
(
'See #254: Using None as function output leads to [] return value'
)
...
@@ -44,7 +44,7 @@ class T_function(unittest.TestCase):
...
@@ -44,7 +44,7 @@ class T_function(unittest.TestCase):
assert
rval
is
None
assert
rval
is
None
def
test_empty
(
self
):
def
test_empty
(
self
):
fn
=
function
([],
[])
#
ok
fn
=
function
([],
[])
#
ok
self
.
assertTrue
(
fn
()
==
[])
self
.
assertTrue
(
fn
()
==
[])
def
test_extra_inputs
(
self
):
def
test_extra_inputs
(
self
):
...
@@ -122,22 +122,22 @@ class T_function(unittest.TestCase):
...
@@ -122,22 +122,22 @@ class T_function(unittest.TestCase):
self
.
assertTrue
(
f
(
s
=
2
,
x
=
1
)
==
0.5
)
self
.
assertTrue
(
f
(
s
=
2
,
x
=
1
)
==
0.5
)
self
.
assertTrue
(
f
(
x
=
2
,
s
=
1
)
==
2.0
)
self
.
assertTrue
(
f
(
x
=
2
,
s
=
1
)
==
2.0
)
self
.
assertTrue
(
f
(
2
,
s
=
1
)
==
2.0
)
self
.
assertTrue
(
f
(
2
,
s
=
1
)
==
2.0
)
checkfor
(
self
,
lambda
:
f
(
2
,
x
=
2.0
),
TypeError
)
#
got multiple values for keyword argument 'x'
checkfor
(
self
,
lambda
:
f
(
2
,
x
=
2.0
),
TypeError
)
#
got multiple values for keyword argument 'x'
checkfor
(
self
,
lambda
:
f
(
x
=
1
),
TypeError
)
#
takes exactly 2 non-keyword arguments (1 given)
checkfor
(
self
,
lambda
:
f
(
x
=
1
),
TypeError
)
#
takes exactly 2 non-keyword arguments (1 given)
checkfor
(
self
,
lambda
:
f
(
s
=
1
),
TypeError
)
#
takes exactly 2 non-keyword arguments (0 given)
checkfor
(
self
,
lambda
:
f
(
s
=
1
),
TypeError
)
#
takes exactly 2 non-keyword arguments (0 given)
def
test_naming_rule1
(
self
):
def
test_naming_rule1
(
self
):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
a
,
s
],
a
/
s
)
f
=
function
([
a
,
s
],
a
/
s
)
self
.
assertTrue
(
f
(
1
,
2
)
==
0.5
)
self
.
assertTrue
(
f
(
1
,
2
)
==
0.5
)
self
.
assertTrue
(
f
(
2
,
1
)
==
2.0
)
self
.
assertTrue
(
f
(
2
,
1
)
==
2.0
)
self
.
assertTrue
(
f
(
2
,
s
=
1
)
==
2.0
)
self
.
assertTrue
(
f
(
2
,
s
=
1
)
==
2.0
)
checkfor
(
self
,
lambda
:
f
(
q
=
2
,
s
=
1
),
TypeError
)
#
got unexpected keyword argument 'q'
checkfor
(
self
,
lambda
:
f
(
q
=
2
,
s
=
1
),
TypeError
)
#
got unexpected keyword argument 'q'
checkfor
(
self
,
lambda
:
f
(
a
=
2
,
s
=
1
),
TypeError
)
#
got unexpected keyword argument 'a'
checkfor
(
self
,
lambda
:
f
(
a
=
2
,
s
=
1
),
TypeError
)
#
got unexpected keyword argument 'a'
def
test_naming_rule2
(
self
):
def
test_naming_rule2
(
self
):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
x
,
s
=
T
.
scalars
(
'xs'
)
# x's name is ignored because it is followed by anonymous parameter a.
# x's name is ignored because it is followed by anonymous parameter a.
...
@@ -146,40 +146,40 @@ class T_function(unittest.TestCase):
...
@@ -146,40 +146,40 @@ class T_function(unittest.TestCase):
self
.
assertTrue
(
f
(
9
,
1
,
2
)
==
0.5
)
self
.
assertTrue
(
f
(
9
,
1
,
2
)
==
0.5
)
self
.
assertTrue
(
f
(
9
,
2
,
1
)
==
2.0
)
self
.
assertTrue
(
f
(
9
,
2
,
1
)
==
2.0
)
self
.
assertTrue
(
f
(
9
,
2
,
s
=
1
)
==
2.0
)
self
.
assertTrue
(
f
(
9
,
2
,
s
=
1
)
==
2.0
)
checkfor
(
self
,
lambda
:
f
(
x
=
9
,
a
=
2
,
s
=
1
),
TypeError
)
#
got unexpected keyword argument 'x'
checkfor
(
self
,
lambda
:
f
(
x
=
9
,
a
=
2
,
s
=
1
),
TypeError
)
#
got unexpected keyword argument 'x'
checkfor
(
self
,
lambda
:
f
(
5.0
,
x
=
9
),
TypeError
)
#
got unexpected keyword argument 'x'
checkfor
(
self
,
lambda
:
f
(
5.0
,
x
=
9
),
TypeError
)
#
got unexpected keyword argument 'x'
def
test_naming_rule3
(
self
):
def
test_naming_rule3
(
self
):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
x
,
s
=
T
.
scalars
(
'xs'
)
# x's name is not ignored (as in test_naming_rule2) because a has a default value.
# x's name is not ignored (as in test_naming_rule2) because a has a default value.
f
=
function
([
x
,
In
(
a
,
value
=
1.0
),
s
],
a
/
s
+
x
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
),
s
],
a
/
s
+
x
)
self
.
assertTrue
(
f
(
9
,
2
,
4
)
==
9.5
)
#
can specify all args in order
self
.
assertTrue
(
f
(
9
,
2
,
4
)
==
9.5
)
#
can specify all args in order
self
.
assertTrue
(
f
(
9
,
2
,
s
=
4
)
==
9.5
)
# can give s as kwarg
self
.
assertTrue
(
f
(
9
,
2
,
s
=
4
)
==
9.5
)
# can give s as kwarg
self
.
assertTrue
(
f
(
9
,
s
=
4
)
==
9.25
)
# can give s as kwarg, get default a
self
.
assertTrue
(
f
(
9
,
s
=
4
)
==
9.25
)
# can give s as kwarg, get default a
self
.
assertTrue
(
f
(
x
=
9
,
s
=
4
)
==
9.25
)
# can give s as kwarg, omit a, x as kw
self
.
assertTrue
(
f
(
x
=
9
,
s
=
4
)
==
9.25
)
# can give s as kwarg, omit a, x as kw
checkfor
(
self
,
lambda
:
f
(
x
=
9
,
a
=
2
,
s
=
4
),
TypeError
)
#
got unexpected keyword argument 'a'
checkfor
(
self
,
lambda
:
f
(
x
=
9
,
a
=
2
,
s
=
4
),
TypeError
)
#
got unexpected keyword argument 'a'
checkfor
(
self
,
lambda
:
f
(),
TypeError
)
#
takes exactly 3 non-keyword arguments (0 given)
checkfor
(
self
,
lambda
:
f
(),
TypeError
)
#
takes exactly 3 non-keyword arguments (0 given)
checkfor
(
self
,
lambda
:
f
(
x
=
9
),
TypeError
)
#
takes exactly 3 non-keyword arguments (1 given)
checkfor
(
self
,
lambda
:
f
(
x
=
9
),
TypeError
)
#
takes exactly 3 non-keyword arguments (1 given)
def
test_naming_rule4
(
self
):
def
test_naming_rule4
(
self
):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
s
],
a
/
s
+
x
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
s
],
a
/
s
+
x
)
self
.
assertTrue
(
f
(
9
,
2
,
4
)
==
9.5
)
#
can specify all args in order
self
.
assertTrue
(
f
(
9
,
2
,
4
)
==
9.5
)
#
can specify all args in order
self
.
assertTrue
(
f
(
9
,
2
,
s
=
4
)
==
9.5
)
# can give s as kwarg
self
.
assertTrue
(
f
(
9
,
2
,
s
=
4
)
==
9.5
)
# can give s as kwarg
self
.
assertTrue
(
f
(
9
,
s
=
4
)
==
9.25
)
# can give s as kwarg, get default a
self
.
assertTrue
(
f
(
9
,
s
=
4
)
==
9.25
)
# can give s as kwarg, get default a
self
.
assertTrue
(
f
(
9
,
a
=
2
,
s
=
4
)
==
9.5
)
# can give s as kwarg, a as kwarg
self
.
assertTrue
(
f
(
9
,
a
=
2
,
s
=
4
)
==
9.5
)
# can give s as kwarg, a as kwarg
self
.
assertTrue
(
f
(
x
=
9
,
a
=
2
,
s
=
4
)
==
9.5
)
# can give all kwargs
self
.
assertTrue
(
f
(
x
=
9
,
a
=
2
,
s
=
4
)
==
9.5
)
# can give all kwargs
self
.
assertTrue
(
f
(
x
=
9
,
s
=
4
)
==
9.25
)
# can give all kwargs
self
.
assertTrue
(
f
(
x
=
9
,
s
=
4
)
==
9.25
)
# can give all kwargs
checkfor
(
self
,
lambda
:
f
(),
TypeError
)
#
takes exactly 3 non-keyword arguments (0 given)
checkfor
(
self
,
lambda
:
f
(),
TypeError
)
#
takes exactly 3 non-keyword arguments (0 given)
checkfor
(
self
,
lambda
:
f
(
5.0
,
x
=
9
),
TypeError
)
#
got multiple values for keyword argument 'x'
checkfor
(
self
,
lambda
:
f
(
5.0
,
x
=
9
),
TypeError
)
#
got multiple values for keyword argument 'x'
def
test_state_access
(
self
):
def
test_state_access
(
self
):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
)],
s
+
a
*
x
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
)],
s
+
a
*
x
)
...
@@ -188,14 +188,14 @@ class T_function(unittest.TestCase):
...
@@ -188,14 +188,14 @@ class T_function(unittest.TestCase):
self
.
assertTrue
(
f
[
s
]
==
0.0
)
self
.
assertTrue
(
f
[
s
]
==
0.0
)
self
.
assertTrue
(
f
(
3.0
)
==
3.0
)
self
.
assertTrue
(
f
(
3.0
)
==
3.0
)
self
.
assertTrue
(
f
(
3.0
,
a
=
2.0
)
==
9.0
)
#
3.0 + 2*3.0
self
.
assertTrue
(
f
(
3.0
,
a
=
2.0
)
==
9.0
)
#
3.0 + 2*3.0
self
.
assertTrue
(
f
[
a
]
==
1.0
)
#
state hasn't changed permanently, we just overrode it last line
self
.
assertTrue
(
f
[
a
]
==
1.0
)
#
state hasn't changed permanently, we just overrode it last line
self
.
assertTrue
(
f
[
s
]
==
9.0
)
self
.
assertTrue
(
f
[
s
]
==
9.0
)
f
[
a
]
=
5.0
f
[
a
]
=
5.0
self
.
assertTrue
(
f
[
a
]
==
5.0
)
self
.
assertTrue
(
f
[
a
]
==
5.0
)
self
.
assertTrue
(
f
(
3.0
)
==
24.0
)
#
9 + 3*5
self
.
assertTrue
(
f
(
3.0
)
==
24.0
)
#
9 + 3*5
self
.
assertTrue
(
f
[
s
]
==
24.0
)
self
.
assertTrue
(
f
[
s
]
==
24.0
)
def
test_same_names
(
self
):
def
test_same_names
(
self
):
...
@@ -217,7 +217,7 @@ class T_function(unittest.TestCase):
...
@@ -217,7 +217,7 @@ class T_function(unittest.TestCase):
checkfor
(
self
,
t
,
TypeError
)
checkfor
(
self
,
t
,
TypeError
)
def
test_copy
(
self
):
def
test_copy
(
self
):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
...
@@ -229,17 +229,17 @@ class T_function(unittest.TestCase):
...
@@ -229,17 +229,17 @@ class T_function(unittest.TestCase):
self
.
assertFalse
(
g
.
container
[
a
]
.
storage
is
f
.
container
[
a
]
.
storage
)
self
.
assertFalse
(
g
.
container
[
a
]
.
storage
is
f
.
container
[
a
]
.
storage
)
self
.
assertFalse
(
g
.
container
[
s
]
.
storage
is
f
.
container
[
s
]
.
storage
)
self
.
assertFalse
(
g
.
container
[
s
]
.
storage
is
f
.
container
[
s
]
.
storage
)
self
.
assertFalse
(
g
.
value
[
a
]
is
not
f
.
value
[
a
])
# should not have been copied
self
.
assertFalse
(
g
.
value
[
a
]
is
not
f
.
value
[
a
])
# should not have been copied
self
.
assertFalse
(
g
.
value
[
s
]
is
f
.
value
[
s
])
# should have been copied because it is mutable.
self
.
assertFalse
(
g
.
value
[
s
]
is
f
.
value
[
s
])
# should have been copied because it is mutable.
self
.
assertFalse
((
g
.
value
[
s
]
!=
f
.
value
[
s
])
.
any
())
# its contents should be identical
self
.
assertFalse
((
g
.
value
[
s
]
!=
f
.
value
[
s
])
.
any
())
# its contents should be identical
self
.
assertTrue
(
f
(
2
,
1
)
==
g
(
2
))
#
they should be in sync, default value should be copied.
self
.
assertTrue
(
f
(
2
,
1
)
==
g
(
2
))
#
they should be in sync, default value should be copied.
self
.
assertTrue
(
f
(
2
,
1
)
==
g
(
2
))
#
they should be in sync, default value should be copied.
self
.
assertTrue
(
f
(
2
,
1
)
==
g
(
2
))
#
they should be in sync, default value should be copied.
f
(
1
,
2
)
# put them out of sync
f
(
1
,
2
)
# put them out of sync
self
.
assertFalse
(
f
(
1
,
2
)
==
g
(
1
,
2
))
#
they should not be equal anymore.
self
.
assertFalse
(
f
(
1
,
2
)
==
g
(
1
,
2
))
#
they should not be equal anymore.
def
test_shared_state0
(
self
):
def
test_shared_state0
(
self
):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
...
@@ -253,7 +253,7 @@ class T_function(unittest.TestCase):
...
@@ -253,7 +253,7 @@ class T_function(unittest.TestCase):
self
.
assertTrue
(
g
[
s
]
==
0
)
self
.
assertTrue
(
g
[
s
]
==
0
)
def
test_shared_state1
(
self
):
def
test_shared_state1
(
self
):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
...
@@ -268,7 +268,7 @@ class T_function(unittest.TestCase):
...
@@ -268,7 +268,7 @@ class T_function(unittest.TestCase):
self
.
assertTrue
(
g
[
s
]
==
4
)
self
.
assertTrue
(
g
[
s
]
==
4
)
def
test_shared_state2
(
self
):
def
test_shared_state2
(
self
):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
...
@@ -281,7 +281,7 @@ class T_function(unittest.TestCase):
...
@@ -281,7 +281,7 @@ class T_function(unittest.TestCase):
f
(
1
,
2
)
f
(
1
,
2
)
self
.
assertTrue
(
f
[
s
]
==
4
)
self
.
assertTrue
(
f
[
s
]
==
4
)
self
.
assertTrue
(
g
[
s
]
==
4
)
self
.
assertTrue
(
g
[
s
]
==
4
)
g
(
1
,
2
)
# has no effect on state
g
(
1
,
2
)
# has no effect on state
self
.
assertTrue
(
f
[
s
]
==
4
)
self
.
assertTrue
(
f
[
s
]
==
4
)
self
.
assertTrue
(
g
[
s
]
==
4
)
self
.
assertTrue
(
g
[
s
]
==
4
)
...
@@ -357,20 +357,20 @@ class T_function(unittest.TestCase):
...
@@ -357,20 +357,20 @@ class T_function(unittest.TestCase):
a
=
T
.
dmatrix
()
a
=
T
.
dmatrix
()
f
=
function
([
a
],
Out
(
a
,
borrow
=
False
))
f
=
function
([
a
],
Out
(
a
,
borrow
=
False
))
o
=
N
.
ones
((
3
,
3
))
o
=
N
.
ones
((
3
,
3
))
assert
o
is
not
f
(
o
)
#
function no longer permits aliasing outputs to inputs
assert
o
is
not
f
(
o
)
#
function no longer permits aliasing outputs to inputs
f
=
function
([
a
],
Out
(
a
*
4
,
borrow
=
False
))
f
=
function
([
a
],
Out
(
a
*
4
,
borrow
=
False
))
o
=
N
.
ones
((
3
,
3
))
o
=
N
.
ones
((
3
,
3
))
four
=
f
(
o
)
four
=
f
(
o
)
assert
numpy
.
all
(
four
==
4
)
assert
numpy
.
all
(
four
==
4
)
f
(
o
+.
1
)
#
should not clobber the memory used to store four
f
(
o
+.
1
)
#
should not clobber the memory used to store four
assert
numpy
.
all
(
four
==
4
)
assert
numpy
.
all
(
four
==
4
)
f
=
function
([
a
],
Out
(
a
*
4
,
borrow
=
True
),
mode
=
theano
.
Mode
(
'c|py_nogc'
,
'fast_run'
))
f
=
function
([
a
],
Out
(
a
*
4
,
borrow
=
True
),
mode
=
theano
.
Mode
(
'c|py_nogc'
,
'fast_run'
))
o
=
N
.
ones
((
3
,
3
))
o
=
N
.
ones
((
3
,
3
))
four
=
f
(
o
)
four
=
f
(
o
)
assert
numpy
.
all
(
four
==
4
)
assert
numpy
.
all
(
four
==
4
)
f
(
o
+.
1
)
#
should clobber the memory used to store four
f
(
o
+.
1
)
#
should clobber the memory used to store four
if
theano
.
config
.
cxx
:
if
theano
.
config
.
cxx
:
assert
not
numpy
.
all
(
four
==
4
)
assert
not
numpy
.
all
(
four
==
4
)
else
:
else
:
...
@@ -423,7 +423,7 @@ class T_function(unittest.TestCase):
...
@@ -423,7 +423,7 @@ class T_function(unittest.TestCase):
class
T_picklefunction
(
unittest
.
TestCase
):
class
T_picklefunction
(
unittest
.
TestCase
):
def
test_deepcopy
(
self
):
def
test_deepcopy
(
self
):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
...
@@ -452,16 +452,16 @@ class T_picklefunction(unittest.TestCase):
...
@@ -452,16 +452,16 @@ class T_picklefunction(unittest.TestCase):
for
((
f_req
,
f_feed
,
f_val
),
(
g_req
,
g_feed
,
g_val
))
in
zip
(
for
((
f_req
,
f_feed
,
f_val
),
(
g_req
,
g_feed
,
g_val
))
in
zip
(
f
.
defaults
,
g
.
defaults
)]))
f
.
defaults
,
g
.
defaults
)]))
self
.
assertFalse
(
g
.
value
[
1
]
is
f
.
value
[
1
])
# should not have been copied
self
.
assertFalse
(
g
.
value
[
1
]
is
f
.
value
[
1
])
# should not have been copied
self
.
assertFalse
(
g
.
value
[
2
]
is
f
.
value
[
2
])
# should have been copied because it is mutable.
self
.
assertFalse
(
g
.
value
[
2
]
is
f
.
value
[
2
])
# should have been copied because it is mutable.
self
.
assertFalse
((
g
.
value
[
2
]
!=
f
.
value
[
2
])
.
any
())
# its contents should be identical
self
.
assertFalse
((
g
.
value
[
2
]
!=
f
.
value
[
2
])
.
any
())
# its contents should be identical
self
.
assertTrue
(
f
(
2
,
1
)
==
g
(
2
))
#
they should be in sync, default value should be copied.
self
.
assertTrue
(
f
(
2
,
1
)
==
g
(
2
))
#
they should be in sync, default value should be copied.
self
.
assertTrue
(
f
(
2
,
1
)
==
g
(
2
))
#
they should be in sync, default value should be copied.
self
.
assertTrue
(
f
(
2
,
1
)
==
g
(
2
))
#
they should be in sync, default value should be copied.
f
(
1
,
2
)
# put them out of sync
f
(
1
,
2
)
# put them out of sync
self
.
assertFalse
(
f
(
1
,
2
)
==
g
(
1
,
2
))
#
they should not be equal anymore.
self
.
assertFalse
(
f
(
1
,
2
)
==
g
(
1
,
2
))
#
they should not be equal anymore.
g
(
1
,
2
)
# put them back in sync
g
(
1
,
2
)
# put them back in sync
self
.
assertTrue
(
f
(
3
)
==
g
(
3
))
# They should be in sync again.
self
.
assertTrue
(
f
(
3
)
==
g
(
3
))
# They should be in sync again.
def
test_deepcopy_shared_container
(
self
):
def
test_deepcopy_shared_container
(
self
):
# Ensure that shared containers remain shared after a deep copy.
# Ensure that shared containers remain shared after a deep copy.
...
@@ -488,7 +488,7 @@ class T_picklefunction(unittest.TestCase):
...
@@ -488,7 +488,7 @@ class T_picklefunction(unittest.TestCase):
self
.
assertTrue
(
fc
[
ac
]
==
2
)
self
.
assertTrue
(
fc
[
ac
]
==
2
)
def
test_pickle
(
self
):
def
test_pickle
(
self
):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
...
@@ -513,17 +513,17 @@ class T_picklefunction(unittest.TestCase):
...
@@ -513,17 +513,17 @@ class T_picklefunction(unittest.TestCase):
self
.
assertFalse
(
x
in
g
.
container
)
self
.
assertFalse
(
x
in
g
.
container
)
self
.
assertFalse
(
x
in
g
.
value
)
self
.
assertFalse
(
x
in
g
.
value
)
self
.
assertFalse
(
g
.
value
[
1
]
is
f
.
value
[
1
])
# should not have been copied
self
.
assertFalse
(
g
.
value
[
1
]
is
f
.
value
[
1
])
# should not have been copied
self
.
assertFalse
(
g
.
value
[
2
]
is
f
.
value
[
2
])
# should have been copied because it is mutable.
self
.
assertFalse
(
g
.
value
[
2
]
is
f
.
value
[
2
])
# should have been copied because it is mutable.
self
.
assertFalse
((
g
.
value
[
2
]
!=
f
.
value
[
2
])
.
any
())
# its contents should be identical
self
.
assertFalse
((
g
.
value
[
2
]
!=
f
.
value
[
2
])
.
any
())
# its contents should be identical
self
.
assertTrue
(
f
(
2
,
1
)
==
g
(
2
))
#
they should be in sync, default value should be copied.
self
.
assertTrue
(
f
(
2
,
1
)
==
g
(
2
))
#
they should be in sync, default value should be copied.
self
.
assertTrue
(
f
(
2
,
1
)
==
g
(
2
))
#
they should be in sync, default value should be copied.
self
.
assertTrue
(
f
(
2
,
1
)
==
g
(
2
))
#
they should be in sync, default value should be copied.
f
(
1
,
2
)
# put them out of sync
f
(
1
,
2
)
# put them out of sync
self
.
assertFalse
(
f
(
1
,
2
)
==
g
(
1
,
2
))
#
they should not be equal anymore.
self
.
assertFalse
(
f
(
1
,
2
)
==
g
(
1
,
2
))
#
they should not be equal anymore.
def
test_optimizations_preserved
(
self
):
def
test_optimizations_preserved
(
self
):
a
=
T
.
dvector
()
# the a is for 'anonymous' (un-named).
a
=
T
.
dvector
()
# the a is for 'anonymous' (un-named).
x
=
T
.
dvector
(
'x'
)
x
=
T
.
dvector
(
'x'
)
s
=
T
.
dvector
(
's'
)
s
=
T
.
dvector
(
's'
)
xm
=
T
.
dmatrix
(
'x'
)
xm
=
T
.
dmatrix
(
'x'
)
...
@@ -567,7 +567,7 @@ class T_picklefunction(unittest.TestCase):
...
@@ -567,7 +567,7 @@ class T_picklefunction(unittest.TestCase):
def
test_multiple_functions
(
self
):
def
test_multiple_functions
(
self
):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
x
,
s
=
T
.
scalars
(
'xs'
)
v
=
T
.
vector
(
'v'
)
v
=
T
.
vector
(
'v'
)
...
@@ -698,7 +698,7 @@ class T_picklefunction(unittest.TestCase):
...
@@ -698,7 +698,7 @@ class T_picklefunction(unittest.TestCase):
class
SomethingToPickle
(
object
):
class
SomethingToPickle
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
x
,
s
=
T
.
scalars
(
'xs'
)
v
=
T
.
vector
(
'v'
)
v
=
T
.
vector
(
'v'
)
...
...
theano/gof/callcache.py
浏览文件 @
3089deda
...
@@ -7,7 +7,7 @@ class CallCache(object):
...
@@ -7,7 +7,7 @@ class CallCache(object):
self
.
filename
=
filename
self
.
filename
=
filename
try
:
try
:
if
filename
is
None
:
if
filename
is
None
:
raise
IOError
(
'bad filename'
)
#
just goes to except
raise
IOError
(
'bad filename'
)
#
just goes to except
f
=
open
(
filename
,
'r'
)
f
=
open
(
filename
,
'r'
)
self
.
cache
=
cPickle
.
load
(
f
)
self
.
cache
=
cPickle
.
load
(
f
)
f
.
close
()
f
.
close
()
...
...
theano/gof/destroyhandler.py
浏览文件 @
3089deda
...
@@ -325,11 +325,11 @@ if 0:
...
@@ -325,11 +325,11 @@ if 0:
fgraph
.
destroy_handler
=
self
fgraph
.
destroy_handler
=
self
self
.
fgraph
=
fgraph
self
.
fgraph
=
fgraph
self
.
destroyers
=
OrderedSet
()
#
set of Apply instances with non-null destroy_map
self
.
destroyers
=
OrderedSet
()
#
set of Apply instances with non-null destroy_map
self
.
view_i
=
{}
# variable -> variable used in calculation
self
.
view_i
=
{}
# variable -> variable used in calculation
self
.
view_o
=
{}
# variable -> set of variables that use this one as a direct input
self
.
view_o
=
{}
# variable -> set of variables that use this one as a direct input
# clients: how many times does an apply use a given variable
# clients: how many times does an apply use a given variable
self
.
clients
=
{}
# variable -> apply -> ninputs
self
.
clients
=
{}
# variable -> apply -> ninputs
self
.
stale_droot
=
True
self
.
stale_droot
=
True
# IG: It's unclear if this is meant to be included in deployed code. It looks like
# IG: It's unclear if this is meant to be included in deployed code. It looks like
...
@@ -725,11 +725,11 @@ class DestroyHandler(toolbox.Bookkeeper):
...
@@ -725,11 +725,11 @@ class DestroyHandler(toolbox.Bookkeeper):
fgraph
.
destroy_handler
=
self
fgraph
.
destroy_handler
=
self
self
.
fgraph
=
fgraph
self
.
fgraph
=
fgraph
self
.
destroyers
=
OrderedSet
()
#
set of Apply instances with non-null destroy_map
self
.
destroyers
=
OrderedSet
()
#
set of Apply instances with non-null destroy_map
self
.
view_i
=
OrderedDict
()
# variable -> variable used in calculation
self
.
view_i
=
OrderedDict
()
# variable -> variable used in calculation
self
.
view_o
=
OrderedDict
()
# variable -> set of variables that use this one as a direct input
self
.
view_o
=
OrderedDict
()
# variable -> set of variables that use this one as a direct input
# clients: how many times does an apply use a given variable
# clients: how many times does an apply use a given variable
self
.
clients
=
OrderedDict
()
# variable -> apply -> ninputs
self
.
clients
=
OrderedDict
()
# variable -> apply -> ninputs
self
.
stale_droot
=
True
self
.
stale_droot
=
True
self
.
debug_all_apps
=
OrderedSet
()
self
.
debug_all_apps
=
OrderedSet
()
...
@@ -754,7 +754,7 @@ class DestroyHandler(toolbox.Bookkeeper):
...
@@ -754,7 +754,7 @@ class DestroyHandler(toolbox.Bookkeeper):
if
self
.
stale_droot
:
if
self
.
stale_droot
:
droot
=
OrderedDict
()
# destroyed view + nonview variables -> foundation
droot
=
OrderedDict
()
# destroyed view + nonview variables -> foundation
impact
=
OrderedDict
()
# destroyed nonview variable -> it + all views of it
impact
=
OrderedDict
()
# destroyed nonview variable -> it + all views of it
root_destroyer
=
OrderedDict
()
# root -> destroyer apply
root_destroyer
=
OrderedDict
()
# root -> destroyer apply
for
app
in
self
.
destroyers
:
for
app
in
self
.
destroyers
:
for
output_idx
,
input_idx_list
in
app
.
op
.
destroy_map
.
items
():
for
output_idx
,
input_idx_list
in
app
.
op
.
destroy_map
.
items
():
...
...
theano/gof/fg.py
浏览文件 @
3089deda
...
@@ -396,7 +396,7 @@ class FunctionGraph(utils.object2):
...
@@ -396,7 +396,7 @@ class FunctionGraph(utils.object2):
# then __prune__ is a no-op.
# then __prune__ is a no-op.
for
output
in
node
.
outputs
:
for
output
in
node
.
outputs
:
# Cannot prune an op which is an output or used somewhere
# Cannot prune an op which is an output or used somewhere
if
self
.
clients
(
output
)
or
output
in
self
.
outputs
:
#
output in self.outputs or self.clients(output):
if
self
.
clients
(
output
)
or
output
in
self
.
outputs
:
#
output in self.outputs or self.clients(output):
return
return
self
.
apply_nodes
.
remove
(
node
)
self
.
apply_nodes
.
remove
(
node
)
self
.
variables
.
difference_update
(
node
.
outputs
)
self
.
variables
.
difference_update
(
node
.
outputs
)
...
...
theano/gof/link.py
浏览文件 @
3089deda
...
@@ -685,7 +685,7 @@ class PerformLinker(LocalLinker):
...
@@ -685,7 +685,7 @@ class PerformLinker(LocalLinker):
f
=
streamline
(
fgraph
,
thunks
,
order
,
post_thunk_old_storage
,
f
=
streamline
(
fgraph
,
thunks
,
order
,
post_thunk_old_storage
,
no_recycling
=
no_recycling
)
no_recycling
=
no_recycling
)
f
.
allow_gc
=
self
.
allow_gc
#
HACK: this is a way of passing an arg to Function.__call__
f
.
allow_gc
=
self
.
allow_gc
#
HACK: this is a way of passing an arg to Function.__call__
add_clear_storage
(
f
,
computed
,
storage_map
)
add_clear_storage
(
f
,
computed
,
storage_map
)
f
.
storage_map
=
storage_map
f
.
storage_map
=
storage_map
...
...
theano/gof/tests/test_graph.py
浏览文件 @
3089deda
...
@@ -142,10 +142,10 @@ class TestClone(X):
...
@@ -142,10 +142,10 @@ class TestClone(X):
node
=
MyOp
.
make_node
(
r1
,
r2
)
node
=
MyOp
.
make_node
(
r1
,
r2
)
node2
=
MyOp
.
make_node
(
node
.
outputs
[
0
],
r5
)
node2
=
MyOp
.
make_node
(
node
.
outputs
[
0
],
r5
)
_
,
new
=
clone
([
r1
,
r2
,
r5
],
node2
.
outputs
,
False
)
_
,
new
=
clone
([
r1
,
r2
,
r5
],
node2
.
outputs
,
False
)
assert
node2
.
outputs
[
0
]
.
type
==
new
[
0
]
.
type
and
node2
.
outputs
[
0
]
is
not
new
[
0
]
# the new output is like the old one but not the same object
assert
node2
.
outputs
[
0
]
.
type
==
new
[
0
]
.
type
and
node2
.
outputs
[
0
]
is
not
new
[
0
]
# the new output is like the old one but not the same object
assert
node2
is
not
new
[
0
]
.
owner
# the new output has a new owner
assert
node2
is
not
new
[
0
]
.
owner
# the new output has a new owner
assert
new
[
0
]
.
owner
.
inputs
[
1
]
is
r5
# the inputs are not copied
assert
new
[
0
]
.
owner
.
inputs
[
1
]
is
r5
# the inputs are not copied
assert
new
[
0
]
.
owner
.
inputs
[
0
]
.
type
==
node
.
outputs
[
0
]
.
type
and
new
[
0
]
.
owner
.
inputs
[
0
]
is
not
node
.
outputs
[
0
]
# check that we copied deeper too
assert
new
[
0
]
.
owner
.
inputs
[
0
]
.
type
==
node
.
outputs
[
0
]
.
type
and
new
[
0
]
.
owner
.
inputs
[
0
]
is
not
node
.
outputs
[
0
]
# check that we copied deeper too
def
test_not_destructive
(
self
):
def
test_not_destructive
(
self
):
# Checks that manipulating a cloned graph leaves the original unchanged.
# Checks that manipulating a cloned graph leaves the original unchanged.
...
...
theano/gof/tests/test_opt.py
浏览文件 @
3089deda
...
@@ -109,18 +109,18 @@ class TestPatternOptimizer:
...
@@ -109,18 +109,18 @@ class TestPatternOptimizer:
def
test_unification_1
(
self
):
def
test_unification_1
(
self
):
x
,
y
,
z
=
inputs
()
x
,
y
,
z
=
inputs
()
e
=
op1
(
op2
(
x
,
x
),
z
)
# the arguments to op2 are the same
e
=
op1
(
op2
(
x
,
x
),
z
)
# the arguments to op2 are the same
g
=
Env
([
x
,
y
,
z
],
[
e
])
g
=
Env
([
x
,
y
,
z
],
[
e
])
PatternOptimizer
((
op1
,
(
op2
,
'1'
,
'1'
),
'2'
),
# they are the same in the pattern
PatternOptimizer
((
op1
,
(
op2
,
'1'
,
'1'
),
'2'
),
# they are the same in the pattern
(
op4
,
'2'
,
'1'
))
.
optimize
(
g
)
(
op4
,
'2'
,
'1'
))
.
optimize
(
g
)
# So the replacement should occur
# So the replacement should occur
assert
str
(
g
)
==
"[Op4(z, x)]"
assert
str
(
g
)
==
"[Op4(z, x)]"
def
test_unification_2
(
self
):
def
test_unification_2
(
self
):
x
,
y
,
z
=
inputs
()
x
,
y
,
z
=
inputs
()
e
=
op1
(
op2
(
x
,
y
),
z
)
# the arguments to op2 are different
e
=
op1
(
op2
(
x
,
y
),
z
)
# the arguments to op2 are different
g
=
Env
([
x
,
y
,
z
],
[
e
])
g
=
Env
([
x
,
y
,
z
],
[
e
])
PatternOptimizer
((
op1
,
(
op2
,
'1'
,
'1'
),
'2'
),
# they are the same in the pattern
PatternOptimizer
((
op1
,
(
op2
,
'1'
,
'1'
),
'2'
),
# they are the same in the pattern
(
op4
,
'2'
,
'1'
))
.
optimize
(
g
)
(
op4
,
'2'
,
'1'
))
.
optimize
(
g
)
# The replacement should NOT occur
# The replacement should NOT occur
assert
str
(
g
)
==
"[Op1(Op2(x, y), z)]"
assert
str
(
g
)
==
"[Op1(Op2(x, y), z)]"
...
@@ -403,7 +403,7 @@ class TestEquilibrium(object):
...
@@ -403,7 +403,7 @@ class TestEquilibrium(object):
PatternSub
((
op4
,
'x'
,
'y'
),
(
op1
,
'x'
,
'y'
)),
PatternSub
((
op4
,
'x'
,
'y'
),
(
op1
,
'x'
,
'y'
)),
PatternSub
((
op3
,
(
op2
,
'x'
,
'y'
)),
(
op4
,
'x'
,
'y'
))
PatternSub
((
op3
,
(
op2
,
'x'
,
'y'
)),
(
op4
,
'x'
,
'y'
))
],
],
max_use_ratio
=
1.
/
len
(
g
.
apply_nodes
))
# each opt can only be applied once
max_use_ratio
=
1.
/
len
(
g
.
apply_nodes
))
# each opt can only be applied once
opt
.
optimize
(
g
)
opt
.
optimize
(
g
)
finally
:
finally
:
_logger
.
setLevel
(
oldlevel
)
_logger
.
setLevel
(
oldlevel
)
...
...
theano/gof/type.py
浏览文件 @
3089deda
...
@@ -226,8 +226,8 @@ class PureType(object):
...
@@ -226,8 +226,8 @@ class PureType(object):
"""
"""
Variable
=
graph
.
Variable
#
the type that will be created by call to make_variable.
Variable
=
graph
.
Variable
#
the type that will be created by call to make_variable.
Constant
=
graph
.
Constant
#
the type that will be created by call to make_constant
Constant
=
graph
.
Constant
#
the type that will be created by call to make_constant
def
filter
(
self
,
data
,
strict
=
False
,
allow_downcast
=
None
):
def
filter
(
self
,
data
,
strict
=
False
,
allow_downcast
=
None
):
"""Required: Return data or an appropriately wrapped/converted data.
"""Required: Return data or an appropriately wrapped/converted data.
...
...
theano/gof/unify.py
浏览文件 @
3089deda
...
@@ -71,7 +71,7 @@ class NotVariable(Variable):
...
@@ -71,7 +71,7 @@ class NotVariable(Variable):
self
.
name
=
name
self
.
name
=
name
self
.
not_options
=
not_options
self
.
not_options
=
not_options
class
VariableInList
:
# not a subclass of Variable
class
VariableInList
:
# not a subclass of Variable
"""
"""
This special kind of variable is matched against a list and unifies
This special kind of variable is matched against a list and unifies
an inner Variable to an OrVariable of the values in the list. For
an inner Variable to an OrVariable of the values in the list. For
...
@@ -341,9 +341,9 @@ def unify_walk(v, o, U):
...
@@ -341,9 +341,9 @@ def unify_walk(v, o, U):
"""
"""
best_v
=
U
[
v
]
best_v
=
U
[
v
]
if
v
is
not
best_v
:
if
v
is
not
best_v
:
return
unify_walk
(
o
,
best_v
,
U
)
# reverse argument order so if o is a Variable this block of code is run again
return
unify_walk
(
o
,
best_v
,
U
)
# reverse argument order so if o is a Variable this block of code is run again
else
:
else
:
return
FALL_THROUGH
# call the next version of unify_walk that matches the type signature
return
FALL_THROUGH
# call the next version of unify_walk that matches the type signature
################################
################################
...
@@ -415,9 +415,9 @@ def unify_merge(v, o, U):
...
@@ -415,9 +415,9 @@ def unify_merge(v, o, U):
"""
"""
best_v
=
U
[
v
]
best_v
=
U
[
v
]
if
v
is
not
best_v
:
if
v
is
not
best_v
:
return
unify_merge
(
o
,
best_v
,
U
)
# reverse argument order so if o is a Variable this block of code is run again
return
unify_merge
(
o
,
best_v
,
U
)
# reverse argument order so if o is a Variable this block of code is run again
else
:
else
:
return
FALL_THROUGH
# call the next version of unify_walk that matches the type signature
return
FALL_THROUGH
# call the next version of unify_walk that matches the type signature
################################
################################
...
...
theano/misc/check_duplicate_key.py
浏览文件 @
3089deda
...
@@ -13,7 +13,7 @@ if len(sys.argv)>1:
...
@@ -13,7 +13,7 @@ if len(sys.argv)>1:
else
:
else
:
dirs
=
os
.
listdir
(
theano
.
config
.
compiledir
)
dirs
=
os
.
listdir
(
theano
.
config
.
compiledir
)
dirs
=
[
os
.
path
.
join
(
theano
.
config
.
compiledir
,
d
)
for
d
in
dirs
]
dirs
=
[
os
.
path
.
join
(
theano
.
config
.
compiledir
,
d
)
for
d
in
dirs
]
keys
=
{}
# key -> nb seen
keys
=
{}
# key -> nb seen
mods
=
{}
mods
=
{}
for
dir
in
dirs
:
for
dir
in
dirs
:
...
@@ -49,13 +49,13 @@ if DISPLAY_DUPLICATE_KEYS:
...
@@ -49,13 +49,13 @@ if DISPLAY_DUPLICATE_KEYS:
if
v
>
1
:
if
v
>
1
:
print
"Duplicate key (
%
i copies):
%
s"
%
(
v
,
cPickle
.
loads
(
k
))
print
"Duplicate key (
%
i copies):
%
s"
%
(
v
,
cPickle
.
loads
(
k
))
nbs_keys
=
{}
# nb seen -> now many key
nbs_keys
=
{}
# nb seen -> now many key
for
val
in
keys
.
values
():
for
val
in
keys
.
values
():
nbs_keys
.
setdefault
(
val
,
0
)
nbs_keys
.
setdefault
(
val
,
0
)
nbs_keys
[
val
]
+=
1
nbs_keys
[
val
]
+=
1
nbs_mod
=
{}
# nb seen -> how many key
nbs_mod
=
{}
# nb seen -> how many key
nbs_mod_to_key
=
{}
#
nb seen -> keys
nbs_mod_to_key
=
{}
#
nb seen -> keys
more_than_one
=
0
more_than_one
=
0
for
mod
,
kk
in
mods
.
iteritems
():
for
mod
,
kk
in
mods
.
iteritems
():
val
=
len
(
kk
)
val
=
len
(
kk
)
...
...
theano/misc/cudamat_utils.py
浏览文件 @
3089deda
...
@@ -71,7 +71,7 @@ try:
...
@@ -71,7 +71,7 @@ try:
cm_mat
.
on_host
=
0
cm_mat
.
on_host
=
0
cm_mat
.
on_device
=
1
cm_mat
.
on_device
=
1
cm_mat
.
is_trans
=
0
cm_mat
.
is_trans
=
0
cm_mat
.
owns_data
=
0
# <-- note: cm_mat dosen't owe the data; x does. So x will delete it.
cm_mat
.
owns_data
=
0
# <-- note: cm_mat dosen't owe the data; x does. So x will delete it.
# x.gpudata is a long. We need a pointer to a float. cast.
# x.gpudata is a long. We need a pointer to a float. cast.
...
@@ -80,12 +80,12 @@ try:
...
@@ -80,12 +80,12 @@ try:
px
=
cudamat
.
CUDAMatrix
(
cm_mat
)
px
=
cudamat
.
CUDAMatrix
(
cm_mat
)
px
.
_base
=
x
# x won't be __del__'ed as long as px is around.
px
.
_base
=
x
# x won't be __del__'ed as long as px is around.
px
.
mat_on_host
=
False
# let cudamat know that we don't have a numpy
px
.
mat_on_host
=
False
# let cudamat know that we don't have a numpy
# array attached.
# array attached.
return
px
return
px
...
...
theano/misc/gnumpy_utils.py
浏览文件 @
3089deda
...
@@ -63,7 +63,7 @@ try:
...
@@ -63,7 +63,7 @@ try:
cm_mat
.
on_host
=
0
cm_mat
.
on_host
=
0
cm_mat
.
on_device
=
1
cm_mat
.
on_device
=
1
cm_mat
.
is_trans
=
0
cm_mat
.
is_trans
=
0
cm_mat
.
owns_data
=
0
# <-- note: cm_mat dosen't owe the data; x does. So x will delete it.
cm_mat
.
owns_data
=
0
# <-- note: cm_mat dosen't owe the data; x does. So x will delete it.
# x.gpudata is a long. We need a pointer to a float. cast.
# x.gpudata is a long. We need a pointer to a float. cast.
...
@@ -72,12 +72,12 @@ try:
...
@@ -72,12 +72,12 @@ try:
px
=
cudamat
.
CUDAMatrix
(
cm_mat
)
px
=
cudamat
.
CUDAMatrix
(
cm_mat
)
px
.
_base
=
x
# x won't be freed if the cudamat object isn't freed.
px
.
_base
=
x
# x won't be freed if the cudamat object isn't freed.
px
.
mat_on_host
=
False
# let cudamat know that we don't have a numpy
px
.
mat_on_host
=
False
# let cudamat know that we don't have a numpy
# array attached.
# array attached.
# Note how gnumpy tracks its cudamat objects: it moves things to the
# Note how gnumpy tracks its cudamat objects: it moves things to the
...
...
theano/misc/hooks/check_whitespace.py
浏览文件 @
3089deda
...
@@ -112,7 +112,7 @@ def run_mercurial_command(hg_command):
...
@@ -112,7 +112,7 @@ def run_mercurial_command(hg_command):
def
parse_stdout_filelist
(
hg_out_filelist
):
def
parse_stdout_filelist
(
hg_out_filelist
):
files
=
hg_out_filelist
.
split
()
files
=
hg_out_filelist
.
split
()
files
=
[
f
.
strip
(
string
.
whitespace
+
"'"
)
for
f
in
files
]
files
=
[
f
.
strip
(
string
.
whitespace
+
"'"
)
for
f
in
files
]
files
=
filter
(
operator
.
truth
,
files
)
# get rid of empty entries
files
=
filter
(
operator
.
truth
,
files
)
# get rid of empty entries
return
files
return
files
def
changed_files
():
def
changed_files
():
...
@@ -221,14 +221,14 @@ def main(argv=None):
...
@@ -221,14 +221,14 @@ def main(argv=None):
else
:
else
:
# parsing succeeded, it is safe to check indentation
# parsing succeeded, it is safe to check indentation
if
not
args
.
no_indentation
:
if
not
args
.
no_indentation
:
was_clean
=
None
# unknown
was_clean
=
None
# unknown
# only calculate was_clean if it will matter to us
# only calculate was_clean if it will matter to us
if
args
.
incremental
or
args
.
incremental_with_patch
:
if
args
.
incremental
or
args
.
incremental_with_patch
:
if
filename
in
changed_filenames
:
if
filename
in
changed_filenames
:
old_file_contents
=
get_file_contents
(
filename
,
revision
=
parent_commit
())
old_file_contents
=
get_file_contents
(
filename
,
revision
=
parent_commit
())
was_clean
=
get_correct_indentation_diff
(
old_file_contents
,
""
)
is
None
was_clean
=
get_correct_indentation_diff
(
old_file_contents
,
""
)
is
None
else
:
else
:
was_clean
=
True
# by default -- it was newly added and thus had no prior problems
was_clean
=
True
# by default -- it was newly added and thus had no prior problems
check_indentation
=
was_clean
or
not
args
.
incremental
check_indentation
=
was_clean
or
not
args
.
incremental
if
check_indentation
:
if
check_indentation
:
...
...
theano/misc/pycuda_utils.py
浏览文件 @
3089deda
...
@@ -60,6 +60,6 @@ def to_cudandarray(x):
...
@@ -60,6 +60,6 @@ def to_cudandarray(x):
for
i
in
x
.
shape
[::
-
1
][:
-
1
]:
for
i
in
x
.
shape
[::
-
1
][:
-
1
]:
strides
.
append
(
strides
[
-
1
]
*
i
)
strides
.
append
(
strides
[
-
1
]
*
i
)
strides
=
tuple
(
strides
[::
-
1
])
strides
=
tuple
(
strides
[::
-
1
])
ptr
=
int
(
x
.
gpudata
)
# in pycuda trunk, y.ptr also works, which is a little cleaner
ptr
=
int
(
x
.
gpudata
)
# in pycuda trunk, y.ptr also works, which is a little cleaner
z
=
cuda
.
from_gpu_pointer
(
ptr
,
x
.
shape
,
strides
,
x
)
z
=
cuda
.
from_gpu_pointer
(
ptr
,
x
.
shape
,
strides
,
x
)
return
z
return
z
theano/sandbox/cuda/basic_ops.py
浏览文件 @
3089deda
...
@@ -12,7 +12,7 @@ from theano.compat.six import StringIO
...
@@ -12,7 +12,7 @@ from theano.compat.six import StringIO
from
theano.gradient
import
grad_undefined
from
theano.gradient
import
grad_undefined
from
theano.scalar
import
Scalar
from
theano.scalar
import
Scalar
scal
=
scalar
# somewhere scalar gets reassigned to be a function
scal
=
scalar
# somewhere scalar gets reassigned to be a function
from
theano.compat.python2x
import
all
,
any
from
theano.compat.python2x
import
all
,
any
...
@@ -3415,7 +3415,7 @@ class GpuAlloc(GpuAllocEmpty):
...
@@ -3415,7 +3415,7 @@ class GpuAlloc(GpuAllocEmpty):
# If the output is a constant, it will have to be deepcopied
# If the output is a constant, it will have to be deepcopied
# each time the function is called. So we do not fold.
# each time the function is called. So we do not fold.
return
False
return
False
elif
(
#
The following ops work inplace of their input id 0.
elif
(
#
The following ops work inplace of their input id 0.
client
[
1
]
==
0
and
client
[
1
]
==
0
and
isinstance
(
client
[
0
]
.
op
,
(
isinstance
(
client
[
0
]
.
op
,
(
# Ops that will work inplace on the Alloc. So if they
# Ops that will work inplace on the Alloc. So if they
...
...
theano/sandbox/cuda/elemwise.py
浏览文件 @
3089deda
...
@@ -260,7 +260,7 @@ class NaiveAlgo(object):
...
@@ -260,7 +260,7 @@ class NaiveAlgo(object):
,
nodename
+
'_scalar_'
,
nodename
+
'_scalar_'
,
get_str_list_logical_scalar
(
node
,
value_str
=
'value0[
%
i]'
)
,
get_str_list_logical_scalar
(
node
,
value_str
=
'value0[
%
i]'
)
,
[
'ii_o
%
i_data[0]'
%
ipos
for
ipos
,
i
in
enumerate
(
node
.
outputs
)]
,
[
'ii_o
%
i_data[0]'
%
ipos
for
ipos
,
i
in
enumerate
(
node
.
outputs
)]
,
sub
=
dict
(
fail
=
'return;'
))
#
TODO: set a failure code somehow!!!
,
sub
=
dict
(
fail
=
'return;'
))
#
TODO: set a failure code somehow!!!
print
>>
sio
,
" "
,
task_code
print
>>
sio
,
" "
,
task_code
print
>>
sio
,
" }"
*
nd
print
>>
sio
,
" }"
*
nd
...
@@ -398,7 +398,7 @@ class NaiveAlgo(object):
...
@@ -398,7 +398,7 @@ class NaiveAlgo(object):
,
nodename
+
'_scalar_'
,
nodename
+
'_scalar_'
,
[
'i
%
i_data_
%
i[0]'
%
(
ipos
,
d
)
for
ipos
,
i
in
enumerate
(
node
.
inputs
)]
,
[
'i
%
i_data_
%
i[0]'
%
(
ipos
,
d
)
for
ipos
,
i
in
enumerate
(
node
.
inputs
)]
,
[
'o
%
i_data_
%
i[0]'
%
(
ipos
,
d
)
for
ipos
,
i
in
enumerate
(
node
.
outputs
)]
,
[
'o
%
i_data_
%
i[0]'
%
(
ipos
,
d
)
for
ipos
,
i
in
enumerate
(
node
.
outputs
)]
,
sub
=
dict
(
fail
=
'return;'
))
#
TODO: set a failure code somehow!!!
,
sub
=
dict
(
fail
=
'return;'
))
#
TODO: set a failure code somehow!!!
if
nd
==
4
:
if
nd
==
4
:
decl_shared_stride
(
n_in
,
n_out
,
nd
)
decl_shared_stride
(
n_in
,
n_out
,
nd
)
...
@@ -473,7 +473,7 @@ class NaiveAlgo(object):
...
@@ -473,7 +473,7 @@ class NaiveAlgo(object):
#, ['i%i_data[i]'%ipos for ipos, i in enumerate(node.inputs)]
#, ['i%i_data[i]'%ipos for ipos, i in enumerate(node.inputs)]
,
get_str_list_logical_scalar
(
node
,
data_str
=
'i
%
i_data[i]'
)
,
get_str_list_logical_scalar
(
node
,
data_str
=
'i
%
i_data[i]'
)
,
[
'o
%
i_data[i]'
%
ipos
for
ipos
,
i
in
enumerate
(
node
.
outputs
)]
,
[
'o
%
i_data[i]'
%
ipos
for
ipos
,
i
in
enumerate
(
node
.
outputs
)]
,
sub
=
dict
(
fail
=
'return;'
))
#
TODO: set a failure code somehow!!!
,
sub
=
dict
(
fail
=
'return;'
))
#
TODO: set a failure code somehow!!!
print
>>
sio
,
" "
,
task_code
print
>>
sio
,
" "
,
task_code
print
>>
sio
,
" }"
print
>>
sio
,
" }"
print
>>
sio
,
"}"
print
>>
sio
,
"}"
...
@@ -844,9 +844,9 @@ nd_collapse_[i]=0;
...
@@ -844,9 +844,9 @@ nd_collapse_[i]=0;
launch_General
(
nodename
,
scalar_op
,
i
,
self
.
sync
)
launch_General
(
nodename
,
scalar_op
,
i
,
self
.
sync
)
print
>>
sio
,
" } break;"
print
>>
sio
,
" } break;"
print
>>
sio
,
"}"
#
end case
print
>>
sio
,
"}"
#
end case
print
>>
sio
,
"return -2;"
# should not get to this point
print
>>
sio
,
"return -2;"
# should not get to this point
print
>>
sio
,
"}"
#
end fct
print
>>
sio
,
"}"
#
end fct
# N.B. cudaGetLastError is called by c_code
# N.B. cudaGetLastError is called by c_code
return
sio
.
getvalue
()
return
sio
.
getvalue
()
...
...
theano/sandbox/cuda/tests/test_basic_ops.py
浏览文件 @
3089deda
...
@@ -87,7 +87,7 @@ def test_careduce():
...
@@ -87,7 +87,7 @@ def test_careduce():
((
1
,
2
),
(
1
,)),
((
1
,
2
),
(
1
,)),
((
100
,
3
,
1300
),
[
1
]),
((
100
,
3
,
1300
),
[
1
]),
((
0
,),
[
0
]),
((
5
,),
[
0
]),
((
0
,),
[
0
]),
((
5
,),
[
0
]),
((
0
,
0
),
[
0
,
1
]),
((
1
,
0
),
[
0
,
1
]),
((
5
,
4
),
[
0
,
1
]),
((
33
,
31
),
[
0
,
1
]),
((
5
,
4
),
[
1
]),
((
5
,
4
),
[
0
]),
#
need something bigger then 32 for some opt test.
((
0
,
0
),
[
0
,
1
]),
((
1
,
0
),
[
0
,
1
]),
((
5
,
4
),
[
0
,
1
]),
((
33
,
31
),
[
0
,
1
]),
((
5
,
4
),
[
1
]),
((
5
,
4
),
[
0
]),
#
need something bigger then 32 for some opt test.
((
5
,
4
,
3
),
[
0
]),
((
5
,
4
,
3
),
[
1
]),
((
5
,
4
,
3
),
[
0
,
1
]),
((
5
,
4
,
3
),
[
2
]),
((
5
,
4
,
3
),
[
1
,
2
]),
((
5
,
4
,
3
),
[
0
,
1
,
2
]),
((
5
,
4
,
3
),
[
0
]),
((
5
,
4
,
3
),
[
1
]),
((
5
,
4
,
3
),
[
0
,
1
]),
((
5
,
4
,
3
),
[
2
]),
((
5
,
4
,
3
),
[
1
,
2
]),
((
5
,
4
,
3
),
[
0
,
1
,
2
]),
((
0
,
0
,
0
,
0
),
[
0
,
1
,
2
,
3
]),
((
0
,
0
,
0
,
0
),
[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
20
),
[
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
0
,
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
1
,
2
,
3
]),
((
5
,
4
,
3
,
20
),
[
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
0
,
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
1
,
2
,
3
]),
...
@@ -95,57 +95,57 @@ def test_careduce():
...
@@ -95,57 +95,57 @@ def test_careduce():
((
5
,
4
,
3
,
20
),
[
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
0
,
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
1
,
2
,
3
]),
((
5
,
4
,
3
,
20
),
[
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
0
,
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
1
,
2
,
3
]),
# test shape bigger then 4096 on each dimension to make sure that we work correctly when we don't have enough thread/block in each dimensions
# test shape bigger then 4096 on each dimension to make sure that we work correctly when we don't have enough thread/block in each dimensions
((
4100
,
3
),
[
0
]),
((
3
,
4101
),
[
0
]),
#
10
((
4100
,
3
),
[
0
]),
((
3
,
4101
),
[
0
]),
#
10
((
1024
,
33
),
[
0
]),
((
33
,
1024
),
[
0
]),
#
10
((
1024
,
33
),
[
0
]),
((
33
,
1024
),
[
0
]),
#
10
((
1025
,
33
),
[
0
]),
((
33
,
1025
),
[
0
]),
#
10
((
1025
,
33
),
[
0
]),
((
33
,
1025
),
[
0
]),
#
10
((
4100
,
3
),
[
1
]),
((
3
,
4101
),
[
1
]),
#
01
((
4100
,
3
),
[
1
]),
((
3
,
4101
),
[
1
]),
#
01
((
1024
,
33
),
[
1
]),
((
33
,
1024
),
[
1
]),
#
01
((
1024
,
33
),
[
1
]),
((
33
,
1024
),
[
1
]),
#
01
((
1025
,
33
),
[
1
]),
((
33
,
1025
),
[
1
]),
#
01
((
1025
,
33
),
[
1
]),
((
33
,
1025
),
[
1
]),
#
01
((
4100
,
3
),
[
0
,
1
]),
((
3
,
4101
),
[
0
,
1
]),
#
11
((
4100
,
3
),
[
0
,
1
]),
((
3
,
4101
),
[
0
,
1
]),
#
11
((
1024
,
33
),
[
0
,
1
]),
((
33
,
1024
),
[
0
,
1
]),
#
01
((
1024
,
33
),
[
0
,
1
]),
((
33
,
1024
),
[
0
,
1
]),
#
01
((
1025
,
33
),
[
0
,
1
]),
((
33
,
1025
),
[
0
,
1
]),
#
01
((
1025
,
33
),
[
0
,
1
]),
((
33
,
1025
),
[
0
,
1
]),
#
01
((
4100
,
4
,
3
),
[
0
]),
((
5
,
4100
,
3
),
[
0
]),
((
5
,
4
,
4100
),
[
0
]),
((
3
,
65536
,
1
),
[
0
]),
#
100
((
4100
,
4
,
3
),
[
0
]),
((
5
,
4100
,
3
),
[
0
]),
((
5
,
4
,
4100
),
[
0
]),
((
3
,
65536
,
1
),
[
0
]),
#
100
((
4100
,
4
,
3
),
[
1
]),
((
5
,
4100
,
3
),
[
1
]),
((
5
,
4
,
4100
),
[
1
]),
#
010
((
4100
,
4
,
3
),
[
1
]),
((
5
,
4100
,
3
),
[
1
]),
((
5
,
4
,
4100
),
[
1
]),
#
010
((
4100
,
4
,
3
),
[
2
]),
((
5
,
4100
,
3
),
[
2
]),
((
5
,
4
,
4100
),
[
2
]),
#
001
((
4100
,
4
,
3
),
[
2
]),
((
5
,
4100
,
3
),
[
2
]),
((
5
,
4
,
4100
),
[
2
]),
#
001
((
4100
,
4
,
3
),
[
0
,
1
]),
((
5
,
4100
,
3
),
[
0
,
1
]),
((
5
,
4
,
4100
),
[
0
,
1
]),
#
110
((
4100
,
4
,
3
),
[
0
,
1
]),
((
5
,
4100
,
3
),
[
0
,
1
]),
((
5
,
4
,
4100
),
[
0
,
1
]),
#
110
((
4100
,
4
,
3
),
[
1
,
2
]),
((
5
,
4100
,
3
),
[
1
,
2
]),
((
5
,
4
,
4100
),
[
1
,
2
]),
#
011
((
4100
,
4
,
3
),
[
1
,
2
]),
((
5
,
4100
,
3
),
[
1
,
2
]),
((
5
,
4
,
4100
),
[
1
,
2
]),
#
011
#((4100,4,3),[0,2]),((5,4100,3),[0,2]),((5,4,4100),[0,2]),#101 ##not implemented
#((4100,4,3),[0,2]),((5,4100,3),[0,2]),((5,4,4100),[0,2]),#101 ##not implemented
((
4100
,
4
,
3
),
[
0
,
1
,
2
]),
((
5
,
4100
,
3
),
[
0
,
1
,
2
]),
((
5
,
4
,
4100
),
[
0
,
1
,
2
]),
#
111
((
4100
,
4
,
3
),
[
0
,
1
,
2
]),
((
5
,
4100
,
3
),
[
0
,
1
,
2
]),
((
5
,
4
,
4100
),
[
0
,
1
,
2
]),
#
111
((
65
,
4
,
3
),
[
0
,
1
,
2
]),
((
5
,
65
,
3
),
[
0
,
1
,
2
]),
((
5
,
4
,
65
),
[
0
,
1
,
2
]),
#
111
((
65
,
4
,
3
),
[
0
,
1
,
2
]),
((
5
,
65
,
3
),
[
0
,
1
,
2
]),
((
5
,
4
,
65
),
[
0
,
1
,
2
]),
#
111
((
4100
,
4
,
3
,
2
),
[
2
,
3
]),
((
4
,
4100
,
3
,
2
),
[
2
,
3
]),
((
4
,
3
,
4100
,
2
),
[
2
,
3
]),
((
4
,
3
,
2
,
4100
),
[
2
,
3
]),
#
0011
((
4100
,
4
,
3
,
2
),
[
2
,
3
]),
((
4
,
4100
,
3
,
2
),
[
2
,
3
]),
((
4
,
3
,
4100
,
2
),
[
2
,
3
]),
((
4
,
3
,
2
,
4100
),
[
2
,
3
]),
#
0011
((
4100
,
4
,
3
,
2
),
[
1
,
3
]),
((
4
,
4100
,
3
,
2
),
[
1
,
3
]),
((
4
,
3
,
4100
,
2
),
[
1
,
3
]),
((
4
,
3
,
2
,
4100
),
[
1
,
3
]),
#
0101
((
4100
,
4
,
3
,
2
),
[
1
,
3
]),
((
4
,
4100
,
3
,
2
),
[
1
,
3
]),
((
4
,
3
,
4100
,
2
),
[
1
,
3
]),
((
4
,
3
,
2
,
4100
),
[
1
,
3
]),
#
0101
((
4100
,
4
,
3
,
2
),
[
0
,
2
,
3
]),
((
4
,
4100
,
3
,
2
),
[
0
,
2
,
3
]),
((
4
,
3
,
4100
,
2
),
[
0
,
2
,
3
]),
#
((4,3,2,4100),[0,2,3]),#1011
((
4100
,
4
,
3
,
2
),
[
0
,
2
,
3
]),
((
4
,
4100
,
3
,
2
),
[
0
,
2
,
3
]),
((
4
,
3
,
4100
,
2
),
[
0
,
2
,
3
]),
#
((4,3,2,4100),[0,2,3]),#1011
((
4100
,
4
,
3
,
2
),
[
1
,
2
,
3
]),
((
4
,
4100
,
3
,
2
),
[
1
,
2
,
3
]),
((
4
,
3
,
4100
,
2
),
[
1
,
2
,
3
]),
((
4
,
3
,
2
,
4100
),
[
1
,
2
,
3
]),
#
0111
((
4100
,
4
,
3
,
2
),
[
1
,
2
,
3
]),
((
4
,
4100
,
3
,
2
),
[
1
,
2
,
3
]),
((
4
,
3
,
4100
,
2
),
[
1
,
2
,
3
]),
((
4
,
3
,
2
,
4100
),
[
1
,
2
,
3
]),
#
0111
((
65
,
4
,
3
,
2
),
[
1
,
2
,
3
]),
((
4
,
65
,
3
,
2
),
[
1
,
2
,
3
]),
((
4
,
3
,
65
,
2
),
[
1
,
2
,
3
]),
((
4
,
3
,
2
,
65
),
[
1
,
2
,
3
]),
#
0111
((
65
,
4
,
3
,
2
),
[
1
,
2
,
3
]),
((
4
,
65
,
3
,
2
),
[
1
,
2
,
3
]),
((
4
,
3
,
65
,
2
),
[
1
,
2
,
3
]),
((
4
,
3
,
2
,
65
),
[
1
,
2
,
3
]),
#
0111
((
4100
,
2
,
3
,
4
),
[
0
,
1
,
2
,
3
]),
((
2
,
4100
,
3
,
4
),
[
0
,
1
,
2
,
3
]),
((
2
,
3
,
4100
,
4
),
[
0
,
1
,
2
,
3
]),
((
2
,
3
,
4
,
4100
),
[
0
,
1
,
2
,
3
]),
((
128
,
1
,
3
,
3
),
[
0
,
1
,
2
,
3
]),
#
1111
((
4100
,
2
,
3
,
4
),
[
0
,
1
,
2
,
3
]),
((
2
,
4100
,
3
,
4
),
[
0
,
1
,
2
,
3
]),
((
2
,
3
,
4100
,
4
),
[
0
,
1
,
2
,
3
]),
((
2
,
3
,
4
,
4100
),
[
0
,
1
,
2
,
3
]),
((
128
,
1
,
3
,
3
),
[
0
,
1
,
2
,
3
]),
#
1111
# test pattern implemented by reshape
# test pattern implemented by reshape
((
4100
,
4
,
3
,
2
),
[
0
]),
((
4
,
4100
,
3
,
2
),
[
0
]),
((
4
,
3
,
4100
,
2
),
[
0
]),
((
4
,
3
,
2
,
4100
),
[
0
]),
#
1000
((
4100
,
4
,
3
,
2
),
[
0
]),
((
4
,
4100
,
3
,
2
),
[
0
]),
((
4
,
3
,
4100
,
2
),
[
0
]),
((
4
,
3
,
2
,
4100
),
[
0
]),
#
1000
((
4100
,
4
,
3
,
2
),
[
1
]),
((
4
,
4100
,
3
,
2
),
[
1
]),
((
4
,
3
,
4100
,
2
),
[
1
]),
((
4
,
3
,
2
,
4100
),
[
1
]),
#
0100
((
4100
,
4
,
3
,
2
),
[
1
]),
((
4
,
4100
,
3
,
2
),
[
1
]),
((
4
,
3
,
4100
,
2
),
[
1
]),
((
4
,
3
,
2
,
4100
),
[
1
]),
#
0100
((
4100
,
4
,
3
,
2
),
[
2
]),
((
4
,
4100
,
3
,
2
),
[
2
]),
((
4
,
3
,
4100
,
2
),
[
2
]),
((
4
,
3
,
2
,
4100
),
[
2
]),
#
0010
((
4100
,
4
,
3
,
2
),
[
2
]),
((
4
,
4100
,
3
,
2
),
[
2
]),
((
4
,
3
,
4100
,
2
),
[
2
]),
((
4
,
3
,
2
,
4100
),
[
2
]),
#
0010
((
4100
,
4
,
3
,
2
),
[
3
]),
((
4
,
4100
,
3
,
2
),
[
3
]),
((
4
,
3
,
4100
,
2
),
[
3
]),
((
4
,
3
,
2
,
4100
),
[
3
]),
#
0001
((
4100
,
4
,
3
,
2
),
[
3
]),
((
4
,
4100
,
3
,
2
),
[
3
]),
((
4
,
3
,
4100
,
2
),
[
3
]),
((
4
,
3
,
2
,
4100
),
[
3
]),
#
0001
# reduce over 2d
# reduce over 2d
((
4100
,
4
,
3
,
2
),
[
1
,
2
]),
((
4
,
4100
,
3
,
2
),
[
1
,
2
]),
((
4
,
3
,
4100
,
2
),
[
1
,
2
]),
((
4
,
3
,
2
,
4100
),
[
1
,
2
]),
#
0110
((
4100
,
4
,
3
,
2
),
[
1
,
2
]),
((
4
,
4100
,
3
,
2
),
[
1
,
2
]),
((
4
,
3
,
4100
,
2
),
[
1
,
2
]),
((
4
,
3
,
2
,
4100
),
[
1
,
2
]),
#
0110
# ((4100,4,3,2),[0,3]),((4,4100,3,2),[0,3]),((4,3,4100,2),[0,3]),((4,3,2,4100),[0,3]),#1001 need 101
# ((4100,4,3,2),[0,3]),((4,4100,3,2),[0,3]),((4,3,4100,2),[0,3]),((4,3,2,4100),[0,3]),#1001 need 101
# ((4100,4,3,2),[0,2]),((4,4100,3,2),[0,2]),((4,3,4100,2),[0,2]),((4,3,2,4100),[0,2]),#1010 not implemented
# ((4100,4,3,2),[0,2]),((4,4100,3,2),[0,2]),((4,3,4100,2),[0,2]),((4,3,2,4100),[0,2]),#1010 not implemented
((
4100
,
4
,
3
,
2
),
[
0
,
1
]),
((
4
,
4100
,
3
,
2
),
[
0
,
1
]),
((
4
,
3
,
4100
,
2
),
[
0
,
1
]),
((
4
,
3
,
2
,
4100
),
[
0
,
1
]),
#
1100
((
4100
,
4
,
3
,
2
),
[
0
,
1
]),
((
4
,
4100
,
3
,
2
),
[
0
,
1
]),
((
4
,
3
,
4100
,
2
),
[
0
,
1
]),
((
4
,
3
,
2
,
4100
),
[
0
,
1
]),
#
1100
# reduce over 3d
# reduce over 3d
# 3d not tested: 1101, 1110, 1111
# 3d not tested: 1101, 1110, 1111
# ((4100,4,3,2),[0,1,3]),((4,4100,3,2),[0,1,3]),((4,3,4100,2),[0,1,3]),((4,3,2,4100),[0,1,3]),#1101 need 101
# ((4100,4,3,2),[0,1,3]),((4,4100,3,2),[0,1,3]),((4,3,4100,2),[0,1,3]),((4,3,2,4100),[0,1,3]),#1101 need 101
((
4100
,
4
,
3
,
2
),
[
0
,
1
,
2
]),
((
4
,
4100
,
3
,
2
),
[
0
,
1
,
2
]),
((
4
,
3
,
4100
,
2
),
[
0
,
1
,
2
]),
((
4
,
3
,
2
,
4100
),
[
0
,
1
,
2
]),
#
1110
((
4100
,
4
,
3
,
2
),
[
0
,
1
,
2
]),
((
4
,
4100
,
3
,
2
),
[
0
,
1
,
2
]),
((
4
,
3
,
4100
,
2
),
[
0
,
1
,
2
]),
((
4
,
3
,
2
,
4100
),
[
0
,
1
,
2
]),
#
1110
# reduce over 4d
# reduce over 4d
((
4100
,
4
,
3
,
2
),
[
0
]),
((
4
,
4100
,
3
,
2
),
[
0
]),
((
4
,
3
,
4100
,
2
),
[
0
]),
((
4
,
3
,
2
,
4100
),
[
0
]),
#
1111
((
4100
,
4
,
3
,
2
),
[
0
]),
((
4
,
4100
,
3
,
2
),
[
0
]),
((
4
,
3
,
4100
,
2
),
[
0
]),
((
4
,
3
,
2
,
4100
),
[
0
]),
#
1111
# reduce over 5d
# reduce over 5d
((
1100
,
2
,
3
,
4
,
5
),
[
0
,
1
,
2
,
3
,
4
]),
((
2
,
1100
,
3
,
4
,
5
),
[
0
,
1
,
2
,
3
,
4
]),
((
2
,
3
,
1100
,
4
,
5
),
[
0
,
1
,
2
,
3
,
4
]),
((
2
,
3
,
4
,
1100
,
5
),
[
0
,
1
,
2
,
3
,
4
]),
((
2
,
3
,
4
,
5
,
1100
),
[
0
,
1
,
2
,
3
,
4
]),
#
11111
((
1100
,
2
,
3
,
4
,
5
),
[
0
,
1
,
2
,
3
,
4
]),
((
2
,
1100
,
3
,
4
,
5
),
[
0
,
1
,
2
,
3
,
4
]),
((
2
,
3
,
1100
,
4
,
5
),
[
0
,
1
,
2
,
3
,
4
]),
((
2
,
3
,
4
,
1100
,
5
),
[
0
,
1
,
2
,
3
,
4
]),
((
2
,
3
,
4
,
5
,
1100
),
[
0
,
1
,
2
,
3
,
4
]),
#
11111
]:
]:
...
@@ -221,7 +221,7 @@ def test_careduce():
...
@@ -221,7 +221,7 @@ def test_careduce():
# test with dimshuffle
# test with dimshuffle
# we shuffle the 2 outer dims.
# we shuffle the 2 outer dims.
for
shape
,
pattern
in
[
#
((5,),[0]),
for
shape
,
pattern
in
[
#
((5,),[0]),
((
5
,
4
),
[
0
,
1
]),
((
5
,
4
),
[
0
]),
((
5
,
4
),
[
0
,
1
]),
((
5
,
4
),
[
0
]),
((
5
,
4
,
3
),
[
0
]),
((
5
,
4
,
3
),
[
0
,
1
]),
((
5
,
4
,
3
),
[
2
]),
((
5
,
4
,
3
),
[
0
,
1
,
2
]),
((
5
,
4
,
3
),
[
0
]),
((
5
,
4
,
3
),
[
0
,
1
]),
((
5
,
4
,
3
),
[
2
]),
((
5
,
4
,
3
),
[
0
,
1
,
2
]),
((
5
,
4
,
3
,
2
),
[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
0
,
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
0
,
2
,
3
]),
...
@@ -1260,7 +1260,7 @@ test_shared_options = theano.tensor.tests.test_sharedvar.makeSharedTester(
...
@@ -1260,7 +1260,7 @@ test_shared_options = theano.tensor.tests.test_sharedvar.makeSharedTester(
shared_constructor_
=
tcn
.
shared_constructor
,
shared_constructor_
=
tcn
.
shared_constructor
,
dtype_
=
'float32'
,
dtype_
=
'float32'
,
get_value_borrow_true_alias_
=
True
,
get_value_borrow_true_alias_
=
True
,
shared_borrow_true_alias_
=
True
,
#
True when the original value is already a CudaNdarray!
shared_borrow_true_alias_
=
True
,
#
True when the original value is already a CudaNdarray!
set_value_borrow_true_alias_
=
True
,
set_value_borrow_true_alias_
=
True
,
set_value_inplace_
=
True
,
set_value_inplace_
=
True
,
set_cast_value_inplace_
=
False
,
set_cast_value_inplace_
=
False
,
...
...
theano/sandbox/cuda/tests/test_bench_loopfusion.py
浏览文件 @
3089deda
...
@@ -93,7 +93,7 @@ class Kouh2008(object):
...
@@ -93,7 +93,7 @@ class Kouh2008(object):
p_unbounded
=
shared_uniform
(
low
=-
0.1
,
high
=
0.1
,
size
=
(
n_out
,),
name
=
'p'
)
p_unbounded
=
shared_uniform
(
low
=-
0.1
,
high
=
0.1
,
size
=
(
n_out
,),
name
=
'p'
)
q_unbounded
=
shared_uniform
(
low
=-
0.1
,
high
=
0.1
,
size
=
(
n_out
,),
name
=
'q'
)
q_unbounded
=
shared_uniform
(
low
=-
0.1
,
high
=
0.1
,
size
=
(
n_out
,),
name
=
'q'
)
r_unbounded
=
shared_uniform
(
low
=-
0.1
,
high
=
0.1
,
size
=
(
n_out
,),
name
=
'r'
)
r_unbounded
=
shared_uniform
(
low
=-
0.1
,
high
=
0.1
,
size
=
(
n_out
,),
name
=
'r'
)
k_unbounded
=
shared_uniform
(
low
=-
0.2
,
high
=
0.2
,
size
=
(
n_out
,),
name
=
'k'
)
# biases
k_unbounded
=
shared_uniform
(
low
=-
0.2
,
high
=
0.2
,
size
=
(
n_out
,),
name
=
'k'
)
# biases
p
=
tensor
.
nnet
.
sigmoid
(
p_unbounded
)
*
e_range_mag
+
e_range_low
p
=
tensor
.
nnet
.
sigmoid
(
p_unbounded
)
*
e_range_mag
+
e_range_low
q
=
tensor
.
nnet
.
sigmoid
(
q_unbounded
)
*
e_range_mag
+
e_range_low
q
=
tensor
.
nnet
.
sigmoid
(
q_unbounded
)
*
e_range_mag
+
e_range_low
...
@@ -171,7 +171,7 @@ class Kouh2008(object):
...
@@ -171,7 +171,7 @@ class Kouh2008(object):
rval
=
cls
.
new_expbounds
(
rng
,
x_list
,
n_out
,
dtype
=
dtype
,
params
=
f_list
+
b_list
,
rval
=
cls
.
new_expbounds
(
rng
,
x_list
,
n_out
,
dtype
=
dtype
,
params
=
f_list
+
b_list
,
exponent_range
=
exponent_range
)
exponent_range
=
exponent_range
)
rval
.
f_list
=
f_list
rval
.
f_list
=
f_list
rval
.
input
=
input
#
add the input to the returned object
rval
.
input
=
input
#
add the input to the returned object
rval
.
filter_l1
=
sum
(
abs
(
fi
)
.
sum
()
for
fi
in
f_list
)
rval
.
filter_l1
=
sum
(
abs
(
fi
)
.
sum
()
for
fi
in
f_list
)
rval
.
filter_l2_sqr
=
sum
((
fi
**
2
)
.
sum
()
for
fi
in
f_list
)
rval
.
filter_l2_sqr
=
sum
((
fi
**
2
)
.
sum
()
for
fi
in
f_list
)
return
rval
return
rval
...
@@ -210,18 +210,18 @@ class Kouh2008(object):
...
@@ -210,18 +210,18 @@ class Kouh2008(object):
out_c_high
=
out_c_low
+
filter_shape
[
1
]
out_c_high
=
out_c_low
+
filter_shape
[
1
]
out_tile
=
out_array
[
out_r_low
:
out_r_high
,
out_c_low
:
out_c_high
,
:]
out_tile
=
out_array
[
out_r_low
:
out_r_high
,
out_c_low
:
out_c_high
,
:]
if
c
%
3
==
0
:
# linear filter
if
c
%
3
==
0
:
# linear filter
if
w_col
<
w
.
shape
[
1
]:
if
w_col
<
w
.
shape
[
1
]:
out_tile
[
...
]
=
pixel_range
(
w
[:,
w_col
])
.
reshape
(
filter_shape
+
(
1
,))
out_tile
[
...
]
=
pixel_range
(
w
[:,
w_col
])
.
reshape
(
filter_shape
+
(
1
,))
w_col
+=
1
w_col
+=
1
if
c
%
3
==
1
:
# E filters
if
c
%
3
==
1
:
# E filters
if
w_col
<
w
.
shape
[
1
]:
if
w_col
<
w
.
shape
[
1
]:
# filters after the 3rd do not get rendered, but are skipped over.
# filters after the 3rd do not get rendered, but are skipped over.
# there are only 3 colour channels.
# there are only 3 colour channels.
for
i
in
xrange
(
min
(
self
.
n_E_quadratic
,
3
)):
for
i
in
xrange
(
min
(
self
.
n_E_quadratic
,
3
)):
out_tile
[:,
:,
i
]
=
pixel_range
(
w
[:,
w_col
+
i
])
.
reshape
(
filter_shape
)
out_tile
[:,
:,
i
]
=
pixel_range
(
w
[:,
w_col
+
i
])
.
reshape
(
filter_shape
)
w_col
+=
self
.
n_E_quadratic
w_col
+=
self
.
n_E_quadratic
if
c
%
3
==
2
:
# S filters
if
c
%
3
==
2
:
# S filters
if
w_col
<
w
.
shape
[
1
]:
if
w_col
<
w
.
shape
[
1
]:
# filters after the 3rd do not get rendered, but are skipped over.
# filters after the 3rd do not get rendered, but are skipped over.
# there are only 3 colour channels.
# there are only 3 colour channels.
...
@@ -244,7 +244,7 @@ class Config(object):
...
@@ -244,7 +244,7 @@ class Config(object):
n_terms
=
4
n_terms
=
4
ft_lr_t0
=
3e-3
ft_lr_t0
=
3e-3
ft_t_decay
=
0
# 50 * 5000 # (units of minibatches) by this N'th pass through the training set
ft_t_decay
=
0
# 50 * 5000 # (units of minibatches) by this N'th pass through the training set
ft_lr_t_decay
=
1e-3
# we will have this learning rate
ft_lr_t_decay
=
1e-3
# we will have this learning rate
ft_cost_classif_l1
=
0
ft_cost_classif_l1
=
0
ft_cost_classif_l2
=
0
ft_cost_classif_l2
=
0
...
@@ -255,11 +255,11 @@ class Config(object):
...
@@ -255,11 +255,11 @@ class Config(object):
ft_cost_in_l1_w
=
0
ft_cost_in_l1_w
=
0
ft_cost_in_l2_w
=
0
ft_cost_in_l2_w
=
0
ft_limit_iters
=
-
1
ft_limit_iters
=
-
1
ft_limit_walltime
=
0
# in seconds 60*60*1 #1 hour
ft_limit_walltime
=
0
# in seconds 60*60*1 #1 hour
ft_batchsize
=
30
ft_batchsize
=
30
ft_epoch_len
=
50000
ft_epoch_len
=
50000
ft_status_interval
=
50
#
property( lambda s:s.ft_epoch_len/s.ft_batchsize)
ft_status_interval
=
50
#
property( lambda s:s.ft_epoch_len/s.ft_batchsize)
ft_validation_interval
=
property
(
lambda
s
:
s
.
ft_epoch_len
/
s
.
ft_batchsize
)
ft_validation_interval
=
property
(
lambda
s
:
s
.
ft_epoch_len
/
s
.
ft_batchsize
)
ft_ntrain_limit
=
0
ft_ntrain_limit
=
0
ft_test_lag1
=
True
ft_test_lag1
=
True
...
...
theano/sandbox/cuda/tests/test_conv_cuda_ndarray.py
浏览文件 @
3089deda
...
@@ -337,28 +337,28 @@ def get_valid_shapes():
...
@@ -337,28 +337,28 @@ def get_valid_shapes():
,
((
4
,
1
,
10
,
10
),
(
1
,
1
,
2
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
10
,
10
),
(
1
,
1
,
2
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
10
,
10
),
(
1
,
1
,
2
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
10
,
10
),
(
1
,
1
,
2
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
20
,
10
),
(
1
,
1
,
2
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
20
,
10
),
(
1
,
1
,
2
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
3
,
2
,
8
,
8
),
(
4
,
2
,
4
,
4
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize
,
((
3
,
2
,
8
,
8
),
(
4
,
2
,
4
,
4
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
4
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize, non-square image
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
4
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize, non-square image
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize, non-square image, non-square kern
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize, non-square image, non-square kern
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
6
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize ,non-square image, non-square kern, kernsize==imgsize on one dim
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
6
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize ,non-square image, non-square kern, kernsize==imgsize on one dim
,
((
16
,
5
,
64
,
64
),
(
8
,
5
,
8
,
8
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# a big one
,
((
16
,
5
,
64
,
64
),
(
8
,
5
,
8
,
8
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# a big one
,
((
16
,
1
,
28
,
28
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# MNIST LeNET layer 1
,
((
16
,
1
,
28
,
28
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# MNIST LeNET layer 1
,
((
20
,
16
,
32
,
32
),
(
1
,
16
,
28
,
28
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# layer 1 backprop to weights
,
((
20
,
16
,
32
,
32
),
(
1
,
16
,
28
,
28
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# layer 1 backprop to weights
,
((
60
,
20
,
28
,
28
),
(
10
,
20
,
5
,
5
),
(
1
,
1
),
(
2
,
2
),
(
1
,
1
))
#
added a test case that fail from test_nnet.py.test_conv_nnet2
,
((
60
,
20
,
28
,
28
),
(
10
,
20
,
5
,
5
),
(
1
,
1
),
(
2
,
2
),
(
1
,
1
))
#
added a test case that fail from test_nnet.py.test_conv_nnet2
,
((
10
,
5
,
28
,
28
),
(
10
,
5
,
5
,
5
),
(
1
,
1
),
(
2
,
2
),
(
1
,
1
))
#
test precedent but reduced that triger the error
,
((
10
,
5
,
28
,
28
),
(
10
,
5
,
5
,
5
),
(
1
,
1
),
(
2
,
2
),
(
1
,
1
))
#
test precedent but reduced that triger the error
# Test more than maxThreadsDim0
# Test more than maxThreadsDim0
,
((
2
,
4
,
13
,
1050
),
(
3
,
4
,
10
,
11
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
2
,
4
,
13
,
1050
),
(
3
,
4
,
10
,
11
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
2
,
4
,
1050
,
13
),
(
3
,
4
,
10
,
11
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
2
,
4
,
1050
,
13
),
(
3
,
4
,
10
,
11
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
]
]
shapes
+=
[
((
60
,
1
,
28
,
28
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 1 layers
shapes
+=
[
((
60
,
1
,
28
,
28
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 1 layers
,
((
60
,
20
,
12
,
12
),
(
30
,
20
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 2 layers
,
((
60
,
20
,
12
,
12
),
(
30
,
20
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 2 layers
,
((
60
,
30
,
8
,
8
),
(
20
,
30
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 bprop 1 full
,
((
60
,
30
,
8
,
8
),
(
20
,
30
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 bprop 1 full
,
((
20
,
60
,
12
,
12
),
(
30
,
60
,
8
,
8
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 bprop 2 valid
,
((
20
,
60
,
12
,
12
),
(
30
,
60
,
8
,
8
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 bprop 2 valid
# , ((1,60,28,28),(20,60,24,24), (1, 1), (1, 1), (1, 1))#test_lenet_28 bprop 2 valid
# , ((1,60,28,28),(20,60,24,24), (1, 1), (1, 1), (1, 1))#test_lenet_28 bprop 2 valid
,
((
10
,
1
,
64
,
64
),
(
20
,
1
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_64 1 layers
,
((
10
,
1
,
64
,
64
),
(
20
,
1
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_64 1 layers
,
((
10
,
20
,
29
,
29
),
(
30
,
20
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_64 2 layers
,
((
10
,
20
,
29
,
29
),
(
30
,
20
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_64 2 layers
,
((
10
,
30
,
23
,
23
),
(
20
,
30
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_64 full
,
((
10
,
30
,
23
,
23
),
(
20
,
30
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_64 full
# , ((20,10,29,29),(30,10,23,23), (1, 1), (1, 1), (1, 1))#test_lenet_64 bprop 1
# , ((20,10,29,29),(30,10,23,23), (1, 1), (1, 1), (1, 1))#test_lenet_64 bprop 1
# , ((1,10,64,64),(20,10,58,58), (1, 1), (1, 1), (1, 1))#test_lenet_64 bprop 2
# , ((1,10,64,64),(20,10,58,58), (1, 1), (1, 1), (1, 1))#test_lenet_64 bprop 2
]
]
...
@@ -461,36 +461,36 @@ def _test_full(cls, mode=None, version=[-1], extra_shapes=[]):
...
@@ -461,36 +461,36 @@ def _test_full(cls, mode=None, version=[-1], extra_shapes=[]):
,
((
4
,
1
,
10
,
10
),
(
1
,
1
,
2
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
10
,
10
),
(
1
,
1
,
2
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
10
,
10
),
(
1
,
1
,
2
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
10
,
10
),
(
1
,
1
,
2
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
20
,
10
),
(
1
,
1
,
2
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
20
,
10
),
(
1
,
1
,
2
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
3
,
2
,
8
,
8
),
(
4
,
2
,
4
,
4
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize
,
((
3
,
2
,
8
,
8
),
(
4
,
2
,
4
,
4
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
4
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize, non-square image
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
4
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize, non-square image
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize, non-square image, non-square kern
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize, non-square image, non-square kern
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
6
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize ,non-square image, non-square kern, kernsize==imgsize on one dim
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
6
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize ,non-square image, non-square kern, kernsize==imgsize on one dim
,
((
16
,
5
,
64
,
64
),
(
8
,
5
,
8
,
8
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# a big one
,
((
16
,
5
,
64
,
64
),
(
8
,
5
,
8
,
8
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# a big one
,
((
16
,
1
,
28
,
28
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# MNIST LeNET layer 1
,
((
16
,
1
,
28
,
28
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# MNIST LeNET layer 1
,
((
20
,
16
,
32
,
32
),
(
1
,
16
,
28
,
28
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# layer 1 backprop to weights
,
((
20
,
16
,
32
,
32
),
(
1
,
16
,
28
,
28
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# layer 1 backprop to weights
# other test
# other test
,
((
3
,
1
,
1
,
1
),
(
2
,
1
,
5
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
kernel bigger then image
,
((
3
,
1
,
1
,
1
),
(
2
,
1
,
5
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
kernel bigger then image
,
((
3
,
2
,
1
,
1
),
(
4
,
2
,
1
,
1
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
3
,
2
,
1
,
1
),
(
4
,
2
,
1
,
1
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
3
,
2
,
4
,
4
),
(
4
,
2
,
2
,
6
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
3
,
2
,
4
,
4
),
(
4
,
2
,
2
,
6
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
3
,
2
,
4
,
4
),
(
4
,
2
,
8
,
6
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
kernel bigger then image
,
((
3
,
2
,
4
,
4
),
(
4
,
2
,
8
,
6
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
kernel bigger then image
,
((
4
,
2
,
10
,
10
),
(
3
,
2
,
2
,
12
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
2
,
10
,
10
),
(
3
,
2
,
2
,
12
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
]
]
shapes
+=
[
shapes
+=
[
# ((60,1,28,28),(20,1,5,5), (1, 1), (1, 1), (1, 1))#test_lenet_28 1 layers
# ((60,1,28,28),(20,1,5,5), (1, 1), (1, 1), (1, 1))#test_lenet_28 1 layers
# , ((60,20,12,12),(30,20,5,5), (1, 1), (1, 1), (1, 1))#test_lenet_28 2 layers
# , ((60,20,12,12),(30,20,5,5), (1, 1), (1, 1), (1, 1))#test_lenet_28 2 layers
((
60
,
30
,
8
,
8
),
(
20
,
30
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 bprop 1 full
((
60
,
30
,
8
,
8
),
(
20
,
30
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 bprop 1 full
# , ((20,60,12,12),(30,60,8,8), (1, 1), (1, 1), (1, 1))#test_lenet_28 bprop 2 valid
# , ((20,60,12,12),(30,60,8,8), (1, 1), (1, 1), (1, 1))#test_lenet_28 bprop 2 valid
# , ((1,60,28,28),(20,60,24,24), (1, 1), (1, 1), (1, 1))#test_lenet_28 bprop 2 valid
# , ((1,60,28,28),(20,60,24,24), (1, 1), (1, 1), (1, 1))#test_lenet_28 bprop 2 valid
# , ((10,1,64,64),(20,1,7,7), (1, 1), (1, 1), (1, 1))#test_lenet_64 1 layers
# , ((10,1,64,64),(20,1,7,7), (1, 1), (1, 1), (1, 1))#test_lenet_64 1 layers
# , ((10,20,29,29),(30,20,7,7), (1, 1), (1, 1), (1, 1))#test_lenet_64 2 layers
# , ((10,20,29,29),(30,20,7,7), (1, 1), (1, 1), (1, 1))#test_lenet_64 2 layers
,
((
10
,
30
,
23
,
23
),
(
20
,
30
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_64 full
,
((
10
,
30
,
23
,
23
),
(
20
,
30
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_64 full
# , ((20,10,29,29),(30,10,23,23), (1, 1), (1, 1), (1, 1))#test_lenet_64 bprop 1
# , ((20,10,29,29),(30,10,23,23), (1, 1), (1, 1), (1, 1))#test_lenet_64 bprop 1
# , ((1,10,64,64),(20,10,58,58), (1, 1), (1, 1), (1, 1))#test_lenet_64 bprop 2
# , ((1,10,64,64),(20,10,58,58), (1, 1), (1, 1), (1, 1))#test_lenet_64 bprop 2
# Test more than maxThreadsDim0
# Test more than maxThreadsDim0
,
((
2
,
4
,
13
,
1050
),
(
3
,
4
,
10
,
11
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
2
,
4
,
13
,
1050
),
(
3
,
4
,
10
,
11
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
2
,
4
,
1050
,
13
),
(
3
,
4
,
10
,
11
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
2
,
4
,
1050
,
13
),
(
3
,
4
,
10
,
11
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
1
,
1
,
44800
,
1
),
(
6
,
1
,
1
,
1
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
This caused crash
,
((
1
,
1
,
44800
,
1
),
(
6
,
1
,
1
,
1
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
This caused crash
]
]
verbose
=
0
verbose
=
0
...
@@ -869,43 +869,43 @@ def benchmark():
...
@@ -869,43 +869,43 @@ def benchmark():
shapes_valid
=
[
shapes_valid
=
[
# test_lenet_28 shape
# test_lenet_28 shape
((
20
,
60
,
12
,
12
),
(
30
,
60
,
8
,
8
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
((
20
,
60
,
12
,
12
),
(
30
,
60
,
8
,
8
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
60
,
20
,
12
,
12
),
(
30
,
20
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
60
,
20
,
12
,
12
),
(
30
,
20
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
60
,
1
,
28
,
28
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
60
,
1
,
28
,
28
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
60
,
28
,
28
),
(
20
,
60
,
24
,
24
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
60
,
28
,
28
),
(
20
,
60
,
24
,
24
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
# test_lenet_32 shape
# test_lenet_32 shape
,
((
20
,
60
,
14
,
14
),
(
30
,
60
,
10
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
20
,
60
,
14
,
14
),
(
30
,
60
,
10
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
60
,
20
,
14
,
14
),
(
30
,
20
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
60
,
20
,
14
,
14
),
(
30
,
20
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
60
,
1
,
32
,
32
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
60
,
1
,
32
,
32
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
60
,
32
,
32
),
(
20
,
60
,
28
,
28
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
60
,
32
,
32
),
(
20
,
60
,
28
,
28
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
# test_lenet_64 shape
# test_lenet_64 shape
,
((
10
,
20
,
29
,
29
),
(
30
,
20
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
10
,
20
,
29
,
29
),
(
30
,
20
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
20
,
10
,
29
,
29
),
(
30
,
10
,
23
,
23
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
20
,
10
,
29
,
29
),
(
30
,
10
,
23
,
23
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
10
,
1
,
64
,
64
),
(
20
,
1
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
10
,
1
,
64
,
64
),
(
20
,
1
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
10
,
64
,
64
),
(
20
,
10
,
58
,
58
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
10
,
64
,
64
),
(
20
,
10
,
58
,
58
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
# test_lenet_108 shape
# test_lenet_108 shape
,
((
10
,
20
,
51
,
51
),
(
30
,
20
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
10
,
20
,
51
,
51
),
(
30
,
20
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
20
,
10
,
51
,
51
),
(
30
,
10
,
45
,
45
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
20
,
10
,
51
,
51
),
(
30
,
10
,
45
,
45
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
10
,
1
,
108
,
108
),
(
20
,
1
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
10
,
1
,
108
,
108
),
(
20
,
1
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
10
,
108
,
108
),
(
20
,
10
,
102
,
102
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
10
,
108
,
108
),
(
20
,
10
,
102
,
102
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
# test_lenet_256 shape
# test_lenet_256 shape
,
((
2
,
20
,
124
,
124
),
(
30
,
20
,
9
,
9
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
2
,
20
,
124
,
124
),
(
30
,
20
,
9
,
9
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
20
,
2
,
124
,
124
),
(
30
,
2
,
116
,
116
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
20
,
2
,
124
,
124
),
(
30
,
2
,
116
,
116
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
2
,
1
,
256
,
256
),
(
20
,
1
,
9
,
9
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
2
,
1
,
256
,
256
),
(
20
,
1
,
9
,
9
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
2
,
256
,
256
),
(
20
,
2
,
248
,
248
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
2
,
256
,
256
),
(
20
,
2
,
248
,
248
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
]
]
shapes_full
=
[
shapes_full
=
[
# test_lenet_28 shape
# test_lenet_28 shape
((
60
,
30
,
8
,
8
),
(
20
,
30
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full
((
60
,
30
,
8
,
8
),
(
20
,
30
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full
# test_lenet_32 shape
# test_lenet_32 shape
,
((
60
,
30
,
10
,
10
),
(
20
,
30
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full conv_full_patch_stack_padded' N=1
,
((
60
,
30
,
10
,
10
),
(
20
,
30
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full conv_full_patch_stack_padded' N=1
# test_lenet_64 shape
# test_lenet_64 shape
,
((
10
,
30
,
23
,
23
),
(
20
,
30
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full conv_full_patch_stack_padded' N=3
,
((
10
,
30
,
23
,
23
),
(
20
,
30
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full conv_full_patch_stack_padded' N=3
# test_lenet_108 shape
# test_lenet_108 shape
,
((
10
,
30
,
45
,
45
),
(
20
,
30
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full 'conv_full_patch_stack_padded' N=9
,
((
10
,
30
,
45
,
45
),
(
20
,
30
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full 'conv_full_patch_stack_padded' N=9
# test_lenet_256 shape
# test_lenet_256 shape
,
((
2
,
30
,
116
,
116
),
(
20
,
30
,
9
,
9
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full conv_reference_full
,
((
2
,
30
,
116
,
116
),
(
20
,
30
,
9
,
9
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full conv_reference_full
]
]
version
=
[
-
1
]
version
=
[
-
1
]
...
...
theano/sandbox/cuda/var.py
浏览文件 @
3089deda
...
@@ -89,7 +89,7 @@ class CudaNdarraySharedVariable(_operators, SharedVariable):
...
@@ -89,7 +89,7 @@ class CudaNdarraySharedVariable(_operators, SharedVariable):
return
self
.
container
.
value
return
self
.
container
.
value
else
:
else
:
return
copy
.
deepcopy
(
self
.
container
.
value
)
return
copy
.
deepcopy
(
self
.
container
.
value
)
else
:
#
return an ndarray
else
:
#
return an ndarray
return
numpy
.
asarray
(
self
.
container
.
value
)
return
numpy
.
asarray
(
self
.
container
.
value
)
def
set_value
(
self
,
value
,
borrow
=
False
):
def
set_value
(
self
,
value
,
borrow
=
False
):
...
@@ -129,7 +129,7 @@ class CudaNdarraySharedVariable(_operators, SharedVariable):
...
@@ -129,7 +129,7 @@ class CudaNdarraySharedVariable(_operators, SharedVariable):
if
not
isinstance
(
value
,
numpy
.
ndarray
):
if
not
isinstance
(
value
,
numpy
.
ndarray
):
# in case this is a cuda_ndarray, we copy it
# in case this is a cuda_ndarray, we copy it
value
=
copy
.
deepcopy
(
value
)
value
=
copy
.
deepcopy
(
value
)
self
.
container
.
value
=
value
# this will copy a numpy ndarray
self
.
container
.
value
=
value
# this will copy a numpy ndarray
def
__getitem__
(
self
,
*
args
):
def
__getitem__
(
self
,
*
args
):
# Defined to explicitly use the implementation from `_operators`, since
# Defined to explicitly use the implementation from `_operators`, since
...
...
theano/sandbox/debug.py
浏览文件 @
3089deda
...
@@ -106,7 +106,7 @@ class DebugLinker(gof.WrapLinker):
...
@@ -106,7 +106,7 @@ class DebugLinker(gof.WrapLinker):
fgraph
=
f
.
fgraph
fgraph
=
f
.
fgraph
for
r
in
fgraph
.
variables
:
for
r
in
fgraph
.
variables
:
if
r
.
owner
is
None
:
if
r
.
owner
is
None
:
r
.
step
=
"value"
# this will be overwritten if r is an input
r
.
step
=
"value"
# this will be overwritten if r is an input
else
:
else
:
r
.
step
=
None
r
.
step
=
None
r
.
value
=
None
r
.
value
=
None
...
...
theano/sandbox/gpuarray/basic_ops.py
浏览文件 @
3089deda
...
@@ -696,7 +696,7 @@ class GpuAlloc(HideC, Alloc):
...
@@ -696,7 +696,7 @@ class GpuAlloc(HideC, Alloc):
# If the output is a constant, it will have to be deepcopied
# If the output is a constant, it will have to be deepcopied
# each time the function is called. So we do not fold.
# each time the function is called. So we do not fold.
return
False
return
False
elif
(
#
The following ops work inplace of their input id 0.
elif
(
#
The following ops work inplace of their input id 0.
client
[
1
]
==
0
and
client
[
1
]
==
0
and
isinstance
(
client
[
0
]
.
op
,
(
isinstance
(
client
[
0
]
.
op
,
(
# Ops that will work inplace on the Alloc. So if they
# Ops that will work inplace on the Alloc. So if they
...
...
theano/sandbox/gpuarray/elemwise.py
浏览文件 @
3089deda
...
@@ -1048,7 +1048,7 @@ class GpuCAReduceCuda(HideC, CAReduceDtype):
...
@@ -1048,7 +1048,7 @@ class GpuCAReduceCuda(HideC, CAReduceDtype):
else
:
else
:
assert
isinstance
(
self
.
scalar_op
,
(
scal
.
Maximum
,
assert
isinstance
(
self
.
scalar_op
,
(
scal
.
Maximum
,
scal
.
Minimum
))
scal
.
Minimum
))
if
self
.
pre_scalar_op
:
# TODO, multi_dtype!
if
self
.
pre_scalar_op
:
# TODO, multi_dtype!
#dtype = node.inputs[0].dtype
#dtype = node.inputs[0].dtype
dtype
=
'float32'
dtype
=
'float32'
...
...
theano/sandbox/gpuarray/tests/test_conv_cuda_ndarray.py
浏览文件 @
3089deda
...
@@ -372,28 +372,28 @@ def get_valid_shapes():
...
@@ -372,28 +372,28 @@ def get_valid_shapes():
,
((
4
,
1
,
10
,
10
),
(
1
,
1
,
2
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
10
,
10
),
(
1
,
1
,
2
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
10
,
10
),
(
1
,
1
,
2
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
10
,
10
),
(
1
,
1
,
2
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
20
,
10
),
(
1
,
1
,
2
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
20
,
10
),
(
1
,
1
,
2
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
3
,
2
,
8
,
8
),
(
4
,
2
,
4
,
4
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize
,
((
3
,
2
,
8
,
8
),
(
4
,
2
,
4
,
4
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
4
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize, non-square image
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
4
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize, non-square image
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize, non-square image, non-square kern
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize, non-square image, non-square kern
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
6
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize ,non-square image, non-square kern, kernsize==imgsize on one dim
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
6
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize ,non-square image, non-square kern, kernsize==imgsize on one dim
,
((
16
,
5
,
64
,
64
),
(
8
,
5
,
8
,
8
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# a big one
,
((
16
,
5
,
64
,
64
),
(
8
,
5
,
8
,
8
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# a big one
,
((
16
,
1
,
28
,
28
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# MNIST LeNET layer 1
,
((
16
,
1
,
28
,
28
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# MNIST LeNET layer 1
,
((
20
,
16
,
32
,
32
),
(
1
,
16
,
28
,
28
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# layer 1 backprop to weights
,
((
20
,
16
,
32
,
32
),
(
1
,
16
,
28
,
28
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# layer 1 backprop to weights
,
((
60
,
20
,
28
,
28
),
(
10
,
20
,
5
,
5
),
(
1
,
1
),
(
2
,
2
),
(
1
,
1
))
#
added a test case that fail from test_nnet.py.test_conv_nnet2
,
((
60
,
20
,
28
,
28
),
(
10
,
20
,
5
,
5
),
(
1
,
1
),
(
2
,
2
),
(
1
,
1
))
#
added a test case that fail from test_nnet.py.test_conv_nnet2
,
((
10
,
5
,
28
,
28
),
(
10
,
5
,
5
,
5
),
(
1
,
1
),
(
2
,
2
),
(
1
,
1
))
#
test precedent but reduced that triger the error
,
((
10
,
5
,
28
,
28
),
(
10
,
5
,
5
,
5
),
(
1
,
1
),
(
2
,
2
),
(
1
,
1
))
#
test precedent but reduced that triger the error
# Test more than maxThreadsDim0
# Test more than maxThreadsDim0
,
((
2
,
4
,
13
,
1050
),
(
3
,
4
,
10
,
11
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
2
,
4
,
13
,
1050
),
(
3
,
4
,
10
,
11
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
2
,
4
,
1050
,
13
),
(
3
,
4
,
10
,
11
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
2
,
4
,
1050
,
13
),
(
3
,
4
,
10
,
11
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
]
]
shapes
+=
[
((
60
,
1
,
28
,
28
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 1 layers
shapes
+=
[
((
60
,
1
,
28
,
28
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 1 layers
,
((
60
,
20
,
12
,
12
),
(
30
,
20
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 2 layers
,
((
60
,
20
,
12
,
12
),
(
30
,
20
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 2 layers
,
((
60
,
30
,
8
,
8
),
(
20
,
30
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 bprop 1 full
,
((
60
,
30
,
8
,
8
),
(
20
,
30
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 bprop 1 full
,
((
20
,
60
,
12
,
12
),
(
30
,
60
,
8
,
8
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 bprop 2 valid
,
((
20
,
60
,
12
,
12
),
(
30
,
60
,
8
,
8
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 bprop 2 valid
# , ((1,60,28,28),(20,60,24,24), (1, 1), (1, 1), (1, 1))#test_lenet_28 bprop 2 valid
# , ((1,60,28,28),(20,60,24,24), (1, 1), (1, 1), (1, 1))#test_lenet_28 bprop 2 valid
,
((
10
,
1
,
64
,
64
),
(
20
,
1
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_64 1 layers
,
((
10
,
1
,
64
,
64
),
(
20
,
1
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_64 1 layers
,
((
10
,
20
,
29
,
29
),
(
30
,
20
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_64 2 layers
,
((
10
,
20
,
29
,
29
),
(
30
,
20
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_64 2 layers
,
((
10
,
30
,
23
,
23
),
(
20
,
30
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_64 full
,
((
10
,
30
,
23
,
23
),
(
20
,
30
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_64 full
# , ((20,10,29,29),(30,10,23,23), (1, 1), (1, 1), (1, 1))#test_lenet_64 bprop 1
# , ((20,10,29,29),(30,10,23,23), (1, 1), (1, 1), (1, 1))#test_lenet_64 bprop 1
# , ((1,10,64,64),(20,10,58,58), (1, 1), (1, 1), (1, 1))#test_lenet_64 bprop 2
# , ((1,10,64,64),(20,10,58,58), (1, 1), (1, 1), (1, 1))#test_lenet_64 bprop 2
]
]
...
@@ -635,30 +635,30 @@ def test_full():
...
@@ -635,30 +635,30 @@ def test_full():
,
((
4
,
1
,
10
,
10
),
(
1
,
1
,
2
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
10
,
10
),
(
1
,
1
,
2
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
10
,
10
),
(
1
,
1
,
2
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
10
,
10
),
(
1
,
1
,
2
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
20
,
10
),
(
1
,
1
,
2
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
1
,
20
,
10
),
(
1
,
1
,
2
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
3
,
2
,
8
,
8
),
(
4
,
2
,
4
,
4
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize
,
((
3
,
2
,
8
,
8
),
(
4
,
2
,
4
,
4
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
4
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize, non-square image
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
4
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize, non-square image
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize, non-square image, non-square kern
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize, non-square image, non-square kern
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
6
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize ,non-square image, non-square kern, kernsize==imgsize on one dim
,
((
3
,
2
,
8
,
6
),
(
4
,
2
,
4
,
6
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
stack, nkern, bsize ,non-square image, non-square kern, kernsize==imgsize on one dim
,
((
16
,
5
,
64
,
64
),
(
8
,
5
,
8
,
8
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# a big one
,
((
16
,
5
,
64
,
64
),
(
8
,
5
,
8
,
8
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# a big one
,
((
16
,
1
,
28
,
28
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# MNIST LeNET layer 1
,
((
16
,
1
,
28
,
28
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# MNIST LeNET layer 1
,
((
20
,
16
,
32
,
32
),
(
1
,
16
,
28
,
28
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# layer 1 backprop to weights
,
((
20
,
16
,
32
,
32
),
(
1
,
16
,
28
,
28
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
# layer 1 backprop to weights
# other test
# other test
,
((
3
,
1
,
1
,
1
),
(
2
,
1
,
5
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
kernel bigger then image
,
((
3
,
1
,
1
,
1
),
(
2
,
1
,
5
,
3
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
kernel bigger then image
,
((
3
,
2
,
1
,
1
),
(
4
,
2
,
1
,
1
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
3
,
2
,
1
,
1
),
(
4
,
2
,
1
,
1
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
3
,
2
,
4
,
4
),
(
4
,
2
,
2
,
6
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
3
,
2
,
4
,
4
),
(
4
,
2
,
2
,
6
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
3
,
2
,
4
,
4
),
(
4
,
2
,
8
,
6
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
kernel bigger then image
,
((
3
,
2
,
4
,
4
),
(
4
,
2
,
8
,
6
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
kernel bigger then image
,
((
4
,
2
,
10
,
10
),
(
3
,
2
,
2
,
12
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
,
((
4
,
2
,
10
,
10
),
(
3
,
2
,
2
,
12
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
]
]
shapes
+=
[
shapes
+=
[
# ((60,1,28,28),(20,1,5,5), (1, 1), (1, 1), (1, 1))#test_lenet_28 1 layers
# ((60,1,28,28),(20,1,5,5), (1, 1), (1, 1), (1, 1))#test_lenet_28 1 layers
# , ((60,20,12,12),(30,20,5,5), (1, 1), (1, 1), (1, 1))#test_lenet_28 2 layers
# , ((60,20,12,12),(30,20,5,5), (1, 1), (1, 1), (1, 1))#test_lenet_28 2 layers
((
60
,
30
,
8
,
8
),
(
20
,
30
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 bprop 1 full
((
60
,
30
,
8
,
8
),
(
20
,
30
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_28 bprop 1 full
# , ((20,60,12,12),(30,60,8,8), (1, 1), (1, 1), (1, 1))#test_lenet_28 bprop 2 valid
# , ((20,60,12,12),(30,60,8,8), (1, 1), (1, 1), (1, 1))#test_lenet_28 bprop 2 valid
# , ((1,60,28,28),(20,60,24,24), (1, 1), (1, 1), (1, 1))#test_lenet_28 bprop 2 valid
# , ((1,60,28,28),(20,60,24,24), (1, 1), (1, 1), (1, 1))#test_lenet_28 bprop 2 valid
# , ((10,1,64,64),(20,1,7,7), (1, 1), (1, 1), (1, 1))#test_lenet_64 1 layers
# , ((10,1,64,64),(20,1,7,7), (1, 1), (1, 1), (1, 1))#test_lenet_64 1 layers
# , ((10,20,29,29),(30,20,7,7), (1, 1), (1, 1), (1, 1))#test_lenet_64 2 layers
# , ((10,20,29,29),(30,20,7,7), (1, 1), (1, 1), (1, 1))#test_lenet_64 2 layers
,
((
10
,
30
,
23
,
23
),
(
20
,
30
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_64 full
,
((
10
,
30
,
23
,
23
),
(
20
,
30
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
test_lenet_64 full
# , ((20,10,29,29),(30,10,23,23), (1, 1), (1, 1), (1, 1))#test_lenet_64 bprop 1
# , ((20,10,29,29),(30,10,23,23), (1, 1), (1, 1), (1, 1))#test_lenet_64 bprop 1
# , ((1,10,64,64),(20,10,58,58), (1, 1), (1, 1), (1, 1))#test_lenet_64 bprop 2
# , ((1,10,64,64),(20,10,58,58), (1, 1), (1, 1), (1, 1))#test_lenet_64 bprop 2
# Test more than maxThreadsDim0
# Test more than maxThreadsDim0
...
@@ -780,43 +780,43 @@ def benchmark():
...
@@ -780,43 +780,43 @@ def benchmark():
shapes_valid
=
[
shapes_valid
=
[
# test_lenet_28 shape
# test_lenet_28 shape
((
20
,
60
,
12
,
12
),
(
30
,
60
,
8
,
8
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
((
20
,
60
,
12
,
12
),
(
30
,
60
,
8
,
8
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
60
,
20
,
12
,
12
),
(
30
,
20
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
60
,
20
,
12
,
12
),
(
30
,
20
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
60
,
1
,
28
,
28
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
60
,
1
,
28
,
28
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
60
,
28
,
28
),
(
20
,
60
,
24
,
24
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
60
,
28
,
28
),
(
20
,
60
,
24
,
24
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
# test_lenet_32 shape
# test_lenet_32 shape
,
((
20
,
60
,
14
,
14
),
(
30
,
60
,
10
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
20
,
60
,
14
,
14
),
(
30
,
60
,
10
,
10
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
60
,
20
,
14
,
14
),
(
30
,
20
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
60
,
20
,
14
,
14
),
(
30
,
20
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
60
,
1
,
32
,
32
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
60
,
1
,
32
,
32
),
(
20
,
1
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
60
,
32
,
32
),
(
20
,
60
,
28
,
28
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
60
,
32
,
32
),
(
20
,
60
,
28
,
28
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
# test_lenet_64 shape
# test_lenet_64 shape
,
((
10
,
20
,
29
,
29
),
(
30
,
20
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
10
,
20
,
29
,
29
),
(
30
,
20
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
20
,
10
,
29
,
29
),
(
30
,
10
,
23
,
23
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
20
,
10
,
29
,
29
),
(
30
,
10
,
23
,
23
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
10
,
1
,
64
,
64
),
(
20
,
1
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
10
,
1
,
64
,
64
),
(
20
,
1
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
10
,
64
,
64
),
(
20
,
10
,
58
,
58
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
10
,
64
,
64
),
(
20
,
10
,
58
,
58
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
# test_lenet_108 shape
# test_lenet_108 shape
,
((
10
,
20
,
51
,
51
),
(
30
,
20
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
10
,
20
,
51
,
51
),
(
30
,
20
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
20
,
10
,
51
,
51
),
(
30
,
10
,
45
,
45
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
20
,
10
,
51
,
51
),
(
30
,
10
,
45
,
45
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
10
,
1
,
108
,
108
),
(
20
,
1
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
10
,
1
,
108
,
108
),
(
20
,
1
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
10
,
108
,
108
),
(
20
,
10
,
102
,
102
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
10
,
108
,
108
),
(
20
,
10
,
102
,
102
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
# test_lenet_256 shape
# test_lenet_256 shape
,
((
2
,
20
,
124
,
124
),
(
30
,
20
,
9
,
9
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
2
,
20
,
124
,
124
),
(
30
,
20
,
9
,
9
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
20
,
2
,
124
,
124
),
(
30
,
2
,
116
,
116
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
20
,
2
,
124
,
124
),
(
30
,
2
,
116
,
116
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
2
,
1
,
256
,
256
),
(
20
,
1
,
9
,
9
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
2
,
1
,
256
,
256
),
(
20
,
1
,
9
,
9
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
2
,
256
,
256
),
(
20
,
2
,
248
,
248
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
,
((
1
,
2
,
256
,
256
),
(
20
,
2
,
248
,
248
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
valid
]
]
shapes_full
=
[
shapes_full
=
[
# test_lenet_28 shape
# test_lenet_28 shape
((
60
,
30
,
8
,
8
),
(
20
,
30
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full
((
60
,
30
,
8
,
8
),
(
20
,
30
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full
# test_lenet_32 shape
# test_lenet_32 shape
,
((
60
,
30
,
10
,
10
),
(
20
,
30
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full conv_full_patch_stack_padded' N=1
,
((
60
,
30
,
10
,
10
),
(
20
,
30
,
5
,
5
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full conv_full_patch_stack_padded' N=1
# test_lenet_64 shape
# test_lenet_64 shape
,
((
10
,
30
,
23
,
23
),
(
20
,
30
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full conv_full_patch_stack_padded' N=3
,
((
10
,
30
,
23
,
23
),
(
20
,
30
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full conv_full_patch_stack_padded' N=3
# test_lenet_108 shape
# test_lenet_108 shape
,
((
10
,
30
,
45
,
45
),
(
20
,
30
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full 'conv_full_patch_stack_padded' N=9
,
((
10
,
30
,
45
,
45
),
(
20
,
30
,
7
,
7
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full 'conv_full_patch_stack_padded' N=9
# test_lenet_256 shape
# test_lenet_256 shape
,
((
2
,
30
,
116
,
116
),
(
20
,
30
,
9
,
9
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full conv_reference_full
,
((
2
,
30
,
116
,
116
),
(
20
,
30
,
9
,
9
),
(
1
,
1
),
(
1
,
1
),
(
1
,
1
))
#
full conv_reference_full
]
]
# shapes_valid=shapes_valid[-1:]
# shapes_valid=shapes_valid[-1:]
...
...
theano/sandbox/gpuarray/tests/test_elemwise.py
浏览文件 @
3089deda
...
@@ -124,39 +124,39 @@ class test_GpuCAReduceCuda(test_GpuCAReduceCPY):
...
@@ -124,39 +124,39 @@ class test_GpuCAReduceCuda(test_GpuCAReduceCPY):
((
1
,
2
),
(
1
,)),
((
1
,
2
),
(
1
,)),
((
100
,
3
,
1300
),
[
1
]),
((
100
,
3
,
1300
),
[
1
]),
((
0
,),
[
0
]),
((
5
,),
[
0
]),
((
0
,),
[
0
]),
((
5
,),
[
0
]),
((
0
,
0
),
[
0
,
1
]),
((
1
,
0
),
[
0
,
1
]),
((
5
,
4
),
[
0
,
1
]),
((
33
,
31
),
[
0
,
1
]),
((
5
,
4
),
[
1
]),
((
5
,
4
),
[
0
]),
#
need something bigger then 32 for some opt test.
((
0
,
0
),
[
0
,
1
]),
((
1
,
0
),
[
0
,
1
]),
((
5
,
4
),
[
0
,
1
]),
((
33
,
31
),
[
0
,
1
]),
((
5
,
4
),
[
1
]),
((
5
,
4
),
[
0
]),
#
need something bigger then 32 for some opt test.
((
5
,
4
,
3
),
[
0
]),
((
5
,
4
,
3
),
[
1
]),
((
5
,
4
,
3
),
[
0
,
1
]),
((
5
,
4
,
3
),
[
2
]),
((
5
,
4
,
3
),
[
1
,
2
]),
((
5
,
4
,
3
),
[
0
,
1
,
2
]),
((
5
,
4
,
3
),
[
0
]),
((
5
,
4
,
3
),
[
1
]),
((
5
,
4
,
3
),
[
0
,
1
]),
((
5
,
4
,
3
),
[
2
]),
((
5
,
4
,
3
),
[
1
,
2
]),
((
5
,
4
,
3
),
[
0
,
1
,
2
]),
((
0
,
0
,
0
,
0
),
[
0
,
1
,
2
,
3
]),
((
0
,
0
,
0
,
0
),
[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
20
),
[
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
0
,
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
1
,
2
,
3
]),
((
5
,
4
,
3
,
20
),
[
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
0
,
1
,
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
0
,
2
,
3
]),
((
5
,
4
,
3
,
2
),
[
1
,
2
,
3
]),
# test shape bigger then 4096 on each dimension to make sure that we work correctly when we don't have enough thread/block in each dimensions
# test shape bigger then 4096 on each dimension to make sure that we work correctly when we don't have enough thread/block in each dimensions
((
4100
,
3
),
[
0
]),
((
3
,
4101
),
[
0
]),
#
10
((
4100
,
3
),
[
0
]),
((
3
,
4101
),
[
0
]),
#
10
((
1024
,
33
),
[
0
]),
((
33
,
1024
),
[
0
]),
#
10
((
1024
,
33
),
[
0
]),
((
33
,
1024
),
[
0
]),
#
10
((
1025
,
33
),
[
0
]),
((
33
,
1025
),
[
0
]),
#
10
((
1025
,
33
),
[
0
]),
((
33
,
1025
),
[
0
]),
#
10
((
4100
,
3
),
[
1
]),
((
3
,
4101
),
[
1
]),
#
01
((
4100
,
3
),
[
1
]),
((
3
,
4101
),
[
1
]),
#
01
((
1024
,
33
),
[
1
]),
((
33
,
1024
),
[
1
]),
#
01
((
1024
,
33
),
[
1
]),
((
33
,
1024
),
[
1
]),
#
01
((
1025
,
33
),
[
1
]),
((
33
,
1025
),
[
1
]),
#
01
((
1025
,
33
),
[
1
]),
((
33
,
1025
),
[
1
]),
#
01
((
4100
,
3
),
[
0
,
1
]),
((
3
,
4101
),
[
0
,
1
]),
#
11
((
4100
,
3
),
[
0
,
1
]),
((
3
,
4101
),
[
0
,
1
]),
#
11
((
1024
,
33
),
[
0
,
1
]),
((
33
,
1024
),
[
0
,
1
]),
#
01
((
1024
,
33
),
[
0
,
1
]),
((
33
,
1024
),
[
0
,
1
]),
#
01
((
1025
,
33
),
[
0
,
1
]),
((
33
,
1025
),
[
0
,
1
]),
#
01
((
1025
,
33
),
[
0
,
1
]),
((
33
,
1025
),
[
0
,
1
]),
#
01
((
4100
,
4
,
3
),
[
0
]),
((
5
,
4100
,
3
),
[
0
]),
((
5
,
4
,
4100
),
[
0
]),
((
3
,
65536
,
1
),
[
0
]),
#
100
((
4100
,
4
,
3
),
[
0
]),
((
5
,
4100
,
3
),
[
0
]),
((
5
,
4
,
4100
),
[
0
]),
((
3
,
65536
,
1
),
[
0
]),
#
100
((
4100
,
4
,
3
),
[
1
]),
((
5
,
4100
,
3
),
[
1
]),
((
5
,
4
,
4100
),
[
1
]),
#
010
((
4100
,
4
,
3
),
[
1
]),
((
5
,
4100
,
3
),
[
1
]),
((
5
,
4
,
4100
),
[
1
]),
#
010
((
4100
,
4
,
3
),
[
2
]),
((
5
,
4100
,
3
),
[
2
]),
((
5
,
4
,
4100
),
[
2
]),
#
001
((
4100
,
4
,
3
),
[
2
]),
((
5
,
4100
,
3
),
[
2
]),
((
5
,
4
,
4100
),
[
2
]),
#
001
((
4100
,
4
,
3
),
[
0
,
1
]),
((
5
,
4100
,
3
),
[
0
,
1
]),
((
5
,
4
,
4100
),
[
0
,
1
]),
#
110
((
4100
,
4
,
3
),
[
0
,
1
]),
((
5
,
4100
,
3
),
[
0
,
1
]),
((
5
,
4
,
4100
),
[
0
,
1
]),
#
110
((
4100
,
4
,
3
),
[
1
,
2
]),
((
5
,
4100
,
3
),
[
1
,
2
]),
((
5
,
4
,
4100
),
[
1
,
2
]),
#
011
((
4100
,
4
,
3
),
[
1
,
2
]),
((
5
,
4100
,
3
),
[
1
,
2
]),
((
5
,
4
,
4100
),
[
1
,
2
]),
#
011
#((4100,4,3),[0,2]),((5,4100,3),[0,2]),((5,4,4100),[0,2]),#101 ##not implemented
#((4100,4,3),[0,2]),((5,4100,3),[0,2]),((5,4,4100),[0,2]),#101 ##not implemented
((
4100
,
4
,
3
),
[
0
,
1
,
2
]),
((
5
,
4100
,
3
),
[
0
,
1
,
2
]),
((
5
,
4
,
4100
),
[
0
,
1
,
2
]),
#
111
((
4100
,
4
,
3
),
[
0
,
1
,
2
]),
((
5
,
4100
,
3
),
[
0
,
1
,
2
]),
((
5
,
4
,
4100
),
[
0
,
1
,
2
]),
#
111
((
65
,
4
,
3
),
[
0
,
1
,
2
]),
((
5
,
65
,
3
),
[
0
,
1
,
2
]),
((
5
,
4
,
65
),
[
0
,
1
,
2
]),
#
111
((
65
,
4
,
3
),
[
0
,
1
,
2
]),
((
5
,
65
,
3
),
[
0
,
1
,
2
]),
((
5
,
4
,
65
),
[
0
,
1
,
2
]),
#
111
((
4100
,
4
,
3
,
2
),
[
2
,
3
]),
((
4
,
4100
,
3
,
2
),
[
2
,
3
]),
((
4
,
3
,
4100
,
2
),
[
2
,
3
]),
((
4
,
3
,
2
,
4100
),
[
2
,
3
]),
#
0011
((
4100
,
4
,
3
,
2
),
[
2
,
3
]),
((
4
,
4100
,
3
,
2
),
[
2
,
3
]),
((
4
,
3
,
4100
,
2
),
[
2
,
3
]),
((
4
,
3
,
2
,
4100
),
[
2
,
3
]),
#
0011
((
4100
,
4
,
3
,
2
),
[
1
,
3
]),
((
4
,
4100
,
3
,
2
),
[
1
,
3
]),
((
4
,
3
,
4100
,
2
),
[
1
,
3
]),
((
4
,
3
,
2
,
4100
),
[
1
,
3
]),
#
0101
((
4100
,
4
,
3
,
2
),
[
1
,
3
]),
((
4
,
4100
,
3
,
2
),
[
1
,
3
]),
((
4
,
3
,
4100
,
2
),
[
1
,
3
]),
((
4
,
3
,
2
,
4100
),
[
1
,
3
]),
#
0101
((
4100
,
4
,
3
,
2
),
[
0
,
2
,
3
]),
((
4
,
4100
,
3
,
2
),
[
0
,
2
,
3
]),
((
4
,
3
,
4100
,
2
),
[
0
,
2
,
3
]),
#
((4,3,2,4100),[0,2,3]),#1011
((
4100
,
4
,
3
,
2
),
[
0
,
2
,
3
]),
((
4
,
4100
,
3
,
2
),
[
0
,
2
,
3
]),
((
4
,
3
,
4100
,
2
),
[
0
,
2
,
3
]),
#
((4,3,2,4100),[0,2,3]),#1011
((
4100
,
4
,
3
,
2
),
[
1
,
2
,
3
]),
((
4
,
4100
,
3
,
2
),
[
1
,
2
,
3
]),
((
4
,
3
,
4100
,
2
),
[
1
,
2
,
3
]),
((
4
,
3
,
2
,
4100
),
[
1
,
2
,
3
]),
#
0111
((
4100
,
4
,
3
,
2
),
[
1
,
2
,
3
]),
((
4
,
4100
,
3
,
2
),
[
1
,
2
,
3
]),
((
4
,
3
,
4100
,
2
),
[
1
,
2
,
3
]),
((
4
,
3
,
2
,
4100
),
[
1
,
2
,
3
]),
#
0111
((
65
,
4
,
3
,
2
),
[
1
,
2
,
3
]),
((
4
,
65
,
3
,
2
),
[
1
,
2
,
3
]),
((
4
,
3
,
65
,
2
),
[
1
,
2
,
3
]),
((
4
,
3
,
2
,
65
),
[
1
,
2
,
3
]),
#
0111
((
65
,
4
,
3
,
2
),
[
1
,
2
,
3
]),
((
4
,
65
,
3
,
2
),
[
1
,
2
,
3
]),
((
4
,
3
,
65
,
2
),
[
1
,
2
,
3
]),
((
4
,
3
,
2
,
65
),
[
1
,
2
,
3
]),
#
0111
((
4100
,
2
,
3
,
4
),
[
0
,
1
,
2
,
3
]),
((
2
,
4100
,
3
,
4
),
[
0
,
1
,
2
,
3
]),
((
2
,
3
,
4100
,
4
),
[
0
,
1
,
2
,
3
]),
((
2
,
3
,
4
,
4100
),
[
0
,
1
,
2
,
3
]),
((
128
,
1
,
2
,
3
),
[
0
,
1
,
2
,
3
]),
#
1111
((
4100
,
2
,
3
,
4
),
[
0
,
1
,
2
,
3
]),
((
2
,
4100
,
3
,
4
),
[
0
,
1
,
2
,
3
]),
((
2
,
3
,
4100
,
4
),
[
0
,
1
,
2
,
3
]),
((
2
,
3
,
4
,
4100
),
[
0
,
1
,
2
,
3
]),
((
128
,
1
,
2
,
3
),
[
0
,
1
,
2
,
3
]),
#
1111
# test pattern implemented by reshape
# test pattern implemented by reshape
# Skip them as this test the op directly, not the optimization with reshape
# Skip them as this test the op directly, not the optimization with reshape
...
...
theano/sandbox/linalg/ops.py
浏览文件 @
3089deda
...
@@ -324,7 +324,7 @@ def no_transpose_symmetric(node):
...
@@ -324,7 +324,7 @@ def no_transpose_symmetric(node):
@register_stabilize
@register_stabilize
@local_optimizer
(
None
)
# XXX: solve is defined later and can't be used here
@local_optimizer
(
None
)
# XXX: solve is defined later and can't be used here
def
psd_solve_with_chol
(
node
):
def
psd_solve_with_chol
(
node
):
if
node
.
op
==
solve
:
if
node
.
op
==
solve
:
A
,
b
=
node
.
inputs
# result is solution Ax=b
A
,
b
=
node
.
inputs
# result is solution Ax=b
...
@@ -340,7 +340,7 @@ def psd_solve_with_chol(node):
...
@@ -340,7 +340,7 @@ def psd_solve_with_chol(node):
@register_stabilize
@register_stabilize
@register_specialize
@register_specialize
@local_optimizer
(
None
)
# XXX: det is defined later and can't be used here
@local_optimizer
(
None
)
# XXX: det is defined later and can't be used here
def
local_det_chol
(
node
):
def
local_det_chol
(
node
):
"""
"""
If we have det(X) and there is already an L=cholesky(X)
If we have det(X) and there is already an L=cholesky(X)
...
...
theano/sandbox/symbolic_module.py
浏览文件 @
3089deda
...
@@ -184,7 +184,7 @@ def compile(smod, initial_values=None):
...
@@ -184,7 +184,7 @@ def compile(smod, initial_values=None):
print
p
print
p
reflected
[
thing
]
=
p
reflected
[
thing
]
=
p
else
:
else
:
reflected
[
thing
]
=
None
#
TODO: how to reflect derived resuls?
reflected
[
thing
]
=
None
#
TODO: how to reflect derived resuls?
elif
issymbolicmethod
(
thing
):
elif
issymbolicmethod
(
thing
):
reflected
[
thing
]
=
compiled_functions
[
thing
]
reflected
[
thing
]
=
compiled_functions
[
thing
]
else
:
else
:
...
@@ -332,12 +332,12 @@ if 0:
...
@@ -332,12 +332,12 @@ if 0:
x
=
T
.
dmatrix
(),
#our points, one point per row
x
=
T
.
dmatrix
(),
#our points, one point per row
w
=
T
.
dmatrix
(),
#first layer weights
w
=
T
.
dmatrix
(),
#first layer weights
b
=
T
.
dvector
(),
#first layer bias
b
=
T
.
dvector
(),
#first layer bias
**
kwargs
#
other things from logistic_regression
**
kwargs
#
other things from logistic_regression
):
):
hid
=
T
.
tanh
(
T
.
dot
(
x
,
w
)
+
b
)
hid
=
T
.
tanh
(
T
.
dot
(
x
,
w
)
+
b
)
if
top_part
:
if
top_part
:
print
'top_part'
,
top_part
,
'kwargs'
,
kwargs
print
'top_part'
,
top_part
,
'kwargs'
,
kwargs
top
=
top_part
(
x
=
hid
,
**
kwargs
)
# SymbolicModule
top
=
top_part
(
x
=
hid
,
**
kwargs
)
# SymbolicModule
def
params
():
return
top
.
params
()
+
[
w
,
b
]
def
params
():
return
top
.
params
()
+
[
w
,
b
]
else
:
else
:
def
params
():
return
[
w
,
b
]
def
params
():
return
[
w
,
b
]
...
@@ -353,7 +353,7 @@ if 0:
...
@@ -353,7 +353,7 @@ if 0:
if
0
:
if
0
:
class
SymbolicModule
(
object
):
class
SymbolicModule
(
object
):
name
=
"__no_name__"
#
name of this module
name
=
"__no_name__"
#
name of this module
variable_table
=
{}
#map strings (names) to Variables
variable_table
=
{}
#map strings (names) to Variables
method_table
=
{}
#map strings to compilable functions
method_table
=
{}
#map strings to compilable functions
...
@@ -385,8 +385,8 @@ if 0:
...
@@ -385,8 +385,8 @@ if 0:
b
=
T
.
dvector
(),
#first layer bias
b
=
T
.
dvector
(),
#first layer bias
v
=
T
.
dmatrix
(),
#second layer weights
v
=
T
.
dmatrix
(),
#second layer weights
c
=
T
.
dvector
(),
#second layer bias
c
=
T
.
dvector
(),
#second layer bias
step
=
T
.
dscalar
(),
#
step size for gradient descent
step
=
T
.
dscalar
(),
#
step size for gradient descent
l2_coef
=
T
.
dscalar
()
#
l2 regularization amount
l2_coef
=
T
.
dscalar
()
#
l2 regularization amount
):
):
"""Idea A:
"""Idea A:
"""
"""
...
...
theano/sandbox/test_theano_object.py
浏览文件 @
3089deda
...
@@ -19,7 +19,7 @@ class MyModule(TheanoObject):
...
@@ -19,7 +19,7 @@ class MyModule(TheanoObject):
super
(
MyModule
,
self
)
.
__init__
()
super
(
MyModule
,
self
)
.
__init__
()
self
.
a
=
self
.
symbolic_member
(
2
)
self
.
a
=
self
.
symbolic_member
(
2
)
self
.
b
=
self
.
symbolic_member
(
3
)
self
.
b
=
self
.
symbolic_member
(
3
)
self
.
c
=
100
#
a constant
self
.
c
=
100
#
a constant
self
.
d
=
[
self
.
symbolic_member
(
5
),
self
.
symbolic_member
(
6
)]
self
.
d
=
[
self
.
symbolic_member
(
5
),
self
.
symbolic_member
(
6
)]
self
.
e
=
[
'a'
,
self
.
symbolic_member
(
6
)]
self
.
e
=
[
'a'
,
self
.
symbolic_member
(
6
)]
...
@@ -46,11 +46,11 @@ def test_outputs():
...
@@ -46,11 +46,11 @@ def test_outputs():
assert
MM
.
add
(
5
)
==
12
assert
MM
.
add
(
5
)
==
12
assert
MM
.
b
.
get
()
==
4
assert
MM
.
b
.
get
()
==
4
MM
.
sub
(
3
)
MM
.
sub
(
3
)
assert
MM
.
b
.
get
()
==
1
#
test get()
assert
MM
.
b
.
get
()
==
1
#
test get()
assert
MM
.
add
(
5
)
==
9
#
test that b's container is shared between add and sub
assert
MM
.
add
(
5
)
==
9
#
test that b's container is shared between add and sub
MM
.
b
.
set
(
2
)
#
test set
MM
.
b
.
set
(
2
)
#
test set
assert
MM
.
b
.
get
()
==
2
#
test get()
assert
MM
.
b
.
get
()
==
2
#
test get()
assert
MM
.
add
(
5
)
==
10
#
test that b's container is shared between add and sub
assert
MM
.
add
(
5
)
==
10
#
test that b's container is shared between add and sub
@run
(
True
)
@run
(
True
)
def
test_submodule
():
def
test_submodule
():
...
@@ -59,7 +59,7 @@ def test_submodule():
...
@@ -59,7 +59,7 @@ def test_submodule():
assert
MM
.
add
(
5
)
==
8
assert
MM
.
add
(
5
)
==
8
MM
.
submodule
.
sub
(
7
)
MM
.
submodule
.
sub
(
7
)
assert
MM
.
submodule
.
b
.
get
()
==
-
3
assert
MM
.
submodule
.
b
.
get
()
==
-
3
assert
MM
.
use_submodule
(
0
)
==
-
2
#
self.a is 1 + self.submodule.b is -3
assert
MM
.
use_submodule
(
0
)
==
-
2
#
self.a is 1 + self.submodule.b is -3
@run
(
False
)
@run
(
False
)
...
...
theano/scalar/basic.py
浏览文件 @
3089deda
...
@@ -3162,7 +3162,7 @@ class Composite(ScalarOp):
...
@@ -3162,7 +3162,7 @@ class Composite(ScalarOp):
res
=
theano
.
compile
.
rebuild_collect_shared
(
res
=
theano
.
compile
.
rebuild_collect_shared
(
inputs
=
inputs
,
inputs
=
inputs
,
outputs
=
outputs
[
0
]
.
owner
.
inputs
,
outputs
=
outputs
[
0
]
.
owner
.
inputs
,
copy_inputs_over
=
False
)
#
Clone also the inputs
copy_inputs_over
=
False
)
#
Clone also the inputs
# 2. We continue this partial clone with the graph in
# 2. We continue this partial clone with the graph in
# the inner Composite
# the inner Composite
res2
=
theano
.
compile
.
rebuild_collect_shared
(
res2
=
theano
.
compile
.
rebuild_collect_shared
(
...
...
theano/scan_module/scan_op.py
浏览文件 @
3089deda
...
@@ -1506,7 +1506,7 @@ class Scan(PureOp):
...
@@ -1506,7 +1506,7 @@ class Scan(PureOp):
"""
"""
output
=
[]
output
=
[]
outer_inp_idx
=
1
# First outer input is timestep index, skip it
outer_inp_idx
=
1
# First outer input is timestep index, skip it
# Handle sequences inputs
# Handle sequences inputs
for
i
in
range
(
self
.
info
[
'n_seqs'
]):
for
i
in
range
(
self
.
info
[
'n_seqs'
]):
...
...
theano/scan_module/scan_opt.py
浏览文件 @
3089deda
...
@@ -692,7 +692,7 @@ class PushOutScanOutput(gof.Optimizer):
...
@@ -692,7 +692,7 @@ class PushOutScanOutput(gof.Optimizer):
outer_dot_inputs
=
[
outer_vector_input
,
outer_dot_inputs
=
[
outer_vector_input
,
outer_matrix_input
.
transpose
()]
outer_matrix_input
.
transpose
()]
outer_dot_output
=
theano
.
tensor
.
dot
(
*
outer_dot_inputs
)
outer_dot_output
=
theano
.
tensor
.
dot
(
*
outer_dot_inputs
)
else
:
# idx_matrix_input == 1
else
:
# idx_matrix_input == 1
outer_dot_inputs
=
[
outer_vector_input
,
outer_dot_inputs
=
[
outer_vector_input
,
outer_matrix_input
]
outer_matrix_input
]
outer_dot_output
=
theano
.
tensor
.
dot
(
*
outer_dot_inputs
)
outer_dot_output
=
theano
.
tensor
.
dot
(
*
outer_dot_inputs
)
...
@@ -725,7 +725,7 @@ class PushOutScanOutput(gof.Optimizer):
...
@@ -725,7 +725,7 @@ class PushOutScanOutput(gof.Optimizer):
sitsot_in_idx
=
nd
.
inputs
.
index
(
args
.
inner_in_sit_sot
[
sitsot_idx
])
sitsot_in_idx
=
nd
.
inputs
.
index
(
args
.
inner_in_sit_sot
[
sitsot_idx
])
dot_in_idx
=
1
-
sitsot_in_idx
# 0 if sitsot_in_idx==1,
dot_in_idx
=
1
-
sitsot_in_idx
# 0 if sitsot_in_idx==1,
# 1 if sitsot_in_idx==0
# 1 if sitsot_in_idx==0
dot_input
=
nd
.
inputs
[
dot_in_idx
]
dot_input
=
nd
.
inputs
[
dot_in_idx
]
...
...
theano/sparse/sandbox/test_sp.py
浏览文件 @
3089deda
...
@@ -140,7 +140,7 @@ class TestSP(unittest.TestCase):
...
@@ -140,7 +140,7 @@ class TestSP(unittest.TestCase):
bsize
=
10
# batch size
bsize
=
10
# batch size
imshp
=
(
8
,
8
)
imshp
=
(
8
,
8
)
kshp
=
(
5
,
5
)
kshp
=
(
5
,
5
)
nkern
=
1
# per output pixel
nkern
=
1
# per output pixel
ssizes
=
((
1
,
1
),
(
2
,
2
))
ssizes
=
((
1
,
1
),
(
2
,
2
))
convmodes
=
(
'full'
,
'valid'
,)
convmodes
=
(
'full'
,
'valid'
,)
...
@@ -182,7 +182,7 @@ class TestSP(unittest.TestCase):
...
@@ -182,7 +182,7 @@ class TestSP(unittest.TestCase):
patch
=
numpy
.
zeros
((
kshp
[
0
],
kshp
[
1
]))
patch
=
numpy
.
zeros
((
kshp
[
0
],
kshp
[
1
]))
for
b
in
xrange
(
bsize
):
for
b
in
xrange
(
bsize
):
for
k
in
xrange
(
nkern
):
for
k
in
xrange
(
nkern
):
pixi
=
0
# pixel index in raster order
pixi
=
0
# pixel index in raster order
for
j
in
xrange
(
outshp
[
1
]):
for
j
in
xrange
(
outshp
[
1
]):
for
i
in
xrange
(
outshp
[
2
]):
for
i
in
xrange
(
outshp
[
2
]):
n
=
j
*
ss
[
0
]
n
=
j
*
ss
[
0
]
...
@@ -225,7 +225,7 @@ class TestSP(unittest.TestCase):
...
@@ -225,7 +225,7 @@ class TestSP(unittest.TestCase):
bsize
=
10
# batch size
bsize
=
10
# batch size
imshp
=
(
5
,
5
)
imshp
=
(
5
,
5
)
kshp
=
((
3
,
3
),
(
2
,
2
))
kshp
=
((
3
,
3
),
(
2
,
2
))
nkerns
=
(
10
,
20
)
# per output pixel
nkerns
=
(
10
,
20
)
# per output pixel
ssizes
=
((
1
,
1
),
(
2
,
2
))
ssizes
=
((
1
,
1
),
(
2
,
2
))
convmodes
=
(
'full'
,
'valid'
,)
convmodes
=
(
'full'
,
'valid'
,)
...
@@ -263,9 +263,9 @@ class TestSP(unittest.TestCase):
...
@@ -263,9 +263,9 @@ class TestSP(unittest.TestCase):
bsize
=
10
# batch size
bsize
=
10
# batch size
imshp
=
(
5
,
5
)
imshp
=
(
5
,
5
)
kshp
=
((
3
,
3
),
(
2
,
2
))
kshp
=
((
3
,
3
),
(
2
,
2
))
nkerns
=
(
3
,
6
)
# per output pixel
nkerns
=
(
3
,
6
)
# per output pixel
ssizes
=
(((
1
,
1
),
(
2
,
2
)),)
ssizes
=
(((
1
,
1
),
(
2
,
2
)),)
convmodes
=
(
'full'
,)
#
'valid',)
convmodes
=
(
'full'
,)
#
'valid',)
# symbolic stuff
# symbolic stuff
kerns
=
[
tensor
.
dmatrix
(),
tensor
.
dmatrix
()]
kerns
=
[
tensor
.
dmatrix
(),
tensor
.
dmatrix
()]
...
@@ -338,7 +338,7 @@ class TestSP(unittest.TestCase):
...
@@ -338,7 +338,7 @@ class TestSP(unittest.TestCase):
def
test_CSMGrad
(
self
):
def
test_CSMGrad
(
self
):
imshp
=
(
3
,
3
)
imshp
=
(
3
,
3
)
nkern
=
1
# per output pixel
nkern
=
1
# per output pixel
kshp
=
(
2
,
2
)
kshp
=
(
2
,
2
)
#ssizes = ((1,1),(2,2))
#ssizes = ((1,1),(2,2))
ssizes
=
((
1
,
1
),)
ssizes
=
((
1
,
1
),)
...
...
theano/tensor/elemwise_cgen.py
浏览文件 @
3089deda
...
@@ -8,7 +8,7 @@ def make_declare(loop_orders, dtypes, sub):
...
@@ -8,7 +8,7 @@ def make_declare(loop_orders, dtypes, sub):
decl
=
""
decl
=
""
for
i
,
(
loop_order
,
dtype
)
in
enumerate
(
zip
(
loop_orders
,
dtypes
)):
for
i
,
(
loop_order
,
dtype
)
in
enumerate
(
zip
(
loop_orders
,
dtypes
)):
var
=
sub
[
'lv
%
i'
%
i
]
# input name corresponding to ith loop variable
var
=
sub
[
'lv
%
i'
%
i
]
# input name corresponding to ith loop variable
# we declare an iteration variable
# we declare an iteration variable
# and an integer for the number of dimensions
# and an integer for the number of dimensions
decl
+=
"""
decl
+=
"""
...
@@ -229,7 +229,7 @@ def make_loop(loop_orders, dtypes, loop_tasks, sub, openmp=None):
...
@@ -229,7 +229,7 @@ def make_loop(loop_orders, dtypes, loop_tasks, sub, openmp=None):
preloops
.
setdefault
(
j
,
""
)
preloops
.
setdefault
(
j
,
""
)
preloops
[
j
]
+=
(
"
%%
(lv
%(i)
s)s_iter = (
%(dtype)
s*)(PyArray_DATA(
%%
(lv
%(i)
s)s));
\n
"
%
locals
())
%
sub
preloops
[
j
]
+=
(
"
%%
(lv
%(i)
s)s_iter = (
%(dtype)
s*)(PyArray_DATA(
%%
(lv
%(i)
s)s));
\n
"
%
locals
())
%
sub
break
break
else
:
# all broadcastable
else
:
# all broadcastable
preloops
.
setdefault
(
0
,
""
)
preloops
.
setdefault
(
0
,
""
)
preloops
[
0
]
+=
(
"
%%
(lv
%(i)
s)s_iter = (
%(dtype)
s*)(PyArray_DATA(
%%
(lv
%(i)
s)s));
\n
"
%
locals
())
%
sub
preloops
[
0
]
+=
(
"
%%
(lv
%(i)
s)s_iter = (
%(dtype)
s*)(PyArray_DATA(
%%
(lv
%(i)
s)s));
\n
"
%
locals
())
%
sub
...
@@ -512,7 +512,7 @@ def make_loop_careduce(loop_orders, dtypes, loop_tasks, sub):
...
@@ -512,7 +512,7 @@ def make_loop_careduce(loop_orders, dtypes, loop_tasks, sub):
preloops
.
setdefault
(
j
,
""
)
preloops
.
setdefault
(
j
,
""
)
preloops
[
j
]
+=
(
"
%%
(lv
%(i)
s)s_iter = (
%(dtype)
s*)(PyArray_DATA(
%%
(lv
%(i)
s)s));
\n
"
%
locals
())
%
sub
preloops
[
j
]
+=
(
"
%%
(lv
%(i)
s)s_iter = (
%(dtype)
s*)(PyArray_DATA(
%%
(lv
%(i)
s)s));
\n
"
%
locals
())
%
sub
break
break
else
:
# all broadcastable
else
:
# all broadcastable
preloops
.
setdefault
(
0
,
""
)
preloops
.
setdefault
(
0
,
""
)
preloops
[
0
]
+=
(
"
%%
(lv
%(i)
s)s_iter = (
%(dtype)
s*)(PyArray_DATA(
%%
(lv
%(i)
s)s));
\n
"
%
locals
())
%
sub
preloops
[
0
]
+=
(
"
%%
(lv
%(i)
s)s_iter = (
%(dtype)
s*)(PyArray_DATA(
%%
(lv
%(i)
s)s));
\n
"
%
locals
())
%
sub
...
...
theano/tensor/nnet/tests/speed_test_conv.py
浏览文件 @
3089deda
...
@@ -89,9 +89,9 @@ def exec_multilayer_conv_nnet_old(conv_mode, ss, bsize, imshp, kshps, nkerns,
...
@@ -89,9 +89,9 @@ def exec_multilayer_conv_nnet_old(conv_mode, ss, bsize, imshp, kshps, nkerns,
from
scipy.signal.signaltools
import
_valfrommode
,
_bvalfromboundary
from
scipy.signal.signaltools
import
_valfrommode
,
_bvalfromboundary
val
=
_valfrommode
(
conv_mode
)
val
=
_valfrommode
(
conv_mode
)
bval
=
_bvalfromboundary
(
'fill'
)
bval
=
_bvalfromboundary
(
'fill'
)
for
b
in
range
(
bsize
):
# loop over batches
for
b
in
range
(
bsize
):
# loop over batches
for
n
in
range
(
nkern
):
# loop over filters
for
n
in
range
(
nkern
):
# loop over filters
for
i
in
range
(
imshp
[
0
]):
# loop over input feature maps
for
i
in
range
(
imshp
[
0
]):
# loop over input feature maps
outval
[
b
,
n
,
...
]
+=
_convolve2d
(
\
outval
[
b
,
n
,
...
]
+=
_convolve2d
(
\
imgval
[
b
,
i
,
...
],
w_flip
[
n
,
i
,
...
],
1
,
val
,
bval
,
0
)[
0
::
ss
[
0
],
0
::
ss
[
1
]]
imgval
[
b
,
i
,
...
],
w_flip
[
n
,
i
,
...
],
1
,
val
,
bval
,
0
)[
0
::
ss
[
0
],
0
::
ss
[
1
]]
ntot
+=
time
.
time
()
-
time1
ntot
+=
time
.
time
()
-
time1
...
@@ -111,14 +111,14 @@ def exec_multilayer_conv_nnet_old(conv_mode, ss, bsize, imshp, kshps, nkerns,
...
@@ -111,14 +111,14 @@ def exec_multilayer_conv_nnet_old(conv_mode, ss, bsize, imshp, kshps, nkerns,
time1
=
time
.
time
()
time1
=
time
.
time
()
for
i
in
range
(
repeat
):
for
i
in
range
(
repeat
):
hidval2_
=
propup2
(
imgval
,
w_flip
)
hidval2_
=
propup2
(
imgval
,
w_flip
)
hidval2
=
hidval2_
#
[:,:,0::ss[0],0::ss[1]]
hidval2
=
hidval2_
#
[:,:,0::ss[0],0::ss[1]]
tctot
+=
time
.
time
()
-
time1
tctot
+=
time
.
time
()
-
time1
if
conv_op_py
:
if
conv_op_py
:
time1
=
time
.
time
()
time1
=
time
.
time
()
for
i
in
range
(
repeat
):
for
i
in
range
(
repeat
):
hidval3_
=
propup3
(
imgval
,
w_flip
)
hidval3_
=
propup3
(
imgval
,
w_flip
)
hidval3
=
hidval3_
#
[:,:,0::ss[0],0::ss[1]]
hidval3
=
hidval3_
#
[:,:,0::ss[0],0::ss[1]]
tpytot
+=
time
.
time
()
-
time1
tpytot
+=
time
.
time
()
-
time1
assert
(
N
.
abs
(
hidval2
-
hidval3
)
<
1e-5
)
.
all
()
assert
(
N
.
abs
(
hidval2
-
hidval3
)
<
1e-5
)
.
all
()
else
:
else
:
...
@@ -183,7 +183,7 @@ def exec_multilayer_conv_nnet(conv_mode, ss, bsize, imshp, kshps, nkerns,
...
@@ -183,7 +183,7 @@ def exec_multilayer_conv_nnet(conv_mode, ss, bsize, imshp, kshps, nkerns,
time1
=
time
.
time
()
time1
=
time
.
time
()
for
i
in
range
(
repeat
):
for
i
in
range
(
repeat
):
hidval2_
=
propup2
(
imgval
,
w_flip
)
hidval2_
=
propup2
(
imgval
,
w_flip
)
hidval2
=
hidval2_
#
[:,:,0::ss[0],0::ss[1]]
hidval2
=
hidval2_
#
[:,:,0::ss[0],0::ss[1]]
tctot
+=
time
.
time
()
-
time1
tctot
+=
time
.
time
()
-
time1
imshp
=
tuple
(
outshp
)
imshp
=
tuple
(
outshp
)
...
@@ -197,22 +197,22 @@ def speed_multilayer_conv():
...
@@ -197,22 +197,22 @@ def speed_multilayer_conv():
# calculate the speed up of different combination of unroll
# calculate the speed up of different combination of unroll
# put the paramter to the same you will try.
# put the paramter to the same you will try.
validate
=
False
# we don't validate the result to have it much faster!
validate
=
False
# we don't validate the result to have it much faster!
repeat
=
3
repeat
=
3
verbose
=
1
verbose
=
1
unroll_batch
=
[
1
,
2
,
3
,
4
,
5
,
6
,
10
]
#
15, 30, 60 always much slower
unroll_batch
=
[
1
,
2
,
3
,
4
,
5
,
6
,
10
]
#
15, 30, 60 always much slower
unroll_kern
=
[
1
,
2
,
3
,
4
,
5
,
6
,
10
]
#
15, 30, 60 always much slower
unroll_kern
=
[
1
,
2
,
3
,
4
,
5
,
6
,
10
]
#
15, 30, 60 always much slower
#unroll_batch = [1,4,5]
#unroll_batch = [1,4,5]
#unroll_kern = [1,4,5]
#unroll_kern = [1,4,5]
#unroll_batch = [1,4]
#unroll_batch = [1,4]
#unroll_kern = [1,4]
#unroll_kern = [1,4]
unroll_patch
=
[
True
,
False
]
unroll_patch
=
[
True
,
False
]
bsize
=
60
# batch size
bsize
=
60
# batch size
imshp_start
=
(
1
,
48
,
48
)
#
un square shape to test more corner case.
imshp_start
=
(
1
,
48
,
48
)
#
un square shape to test more corner case.
kshps
=
([
11
,
12
],)
#
un square shape to test more corner case.
kshps
=
([
11
,
12
],)
#
un square shape to test more corner case.
nkerns
=
[
60
]
# per output pixel
nkerns
=
[
60
]
# per output pixel
ssizes
=
[(
1
,
1
),
]
#
(1,1)]#(2,2) bugged
ssizes
=
[(
1
,
1
),
]
#
(1,1)]#(2,2) bugged
convmodes
=
[
'valid'
,
'full'
]
convmodes
=
[
'valid'
,
'full'
]
do_convolve2
=
False
do_convolve2
=
False
a
=
T
.
dmatrix
()
a
=
T
.
dmatrix
()
...
@@ -246,9 +246,9 @@ def speed_multilayer_conv():
...
@@ -246,9 +246,9 @@ def speed_multilayer_conv():
if
unroll_b
==
1
and
unroll_k
==
1
:
if
unroll_b
==
1
and
unroll_k
==
1
:
# print "unroll 1/1",tctot
# print "unroll 1/1",tctot
worst
=
tctot
worst
=
tctot
timing
[
n_b
,
n_k
]
=
[
tctot
,
tpytot
,
ntot
]
#
[sum(tctot), sum(tpytot), sum(ntot)]
timing
[
n_b
,
n_k
]
=
[
tctot
,
tpytot
,
ntot
]
#
[sum(tctot), sum(tpytot), sum(ntot)]
if
not
t_
:
if
not
t_
:
t
=
timing
[:,
:,
0
,
:]
#
We select only the c timing.
t
=
timing
[:,
:,
0
,
:]
#
We select only the c timing.
else
:
else
:
t
=
t_
t
=
t_
t
=
N
.
asarray
(
t
)
t
=
N
.
asarray
(
t
)
...
...
theano/tensor/nnet/tests/test_nnet.py
浏览文件 @
3089deda
...
@@ -1137,7 +1137,7 @@ def test_argmax_pushdown():
...
@@ -1137,7 +1137,7 @@ def test_argmax_pushdown():
# print 'AFTER'
# print 'AFTER'
# for node in fgraph.toposort():
# for node in fgraph.toposort():
# print node.op
# print node.op
assert
len
(
fgraph
.
toposort
())
==
4
# an output_guard is second
assert
len
(
fgraph
.
toposort
())
==
4
# an output_guard is second
assert
isinstance
(
fgraph
.
toposort
()[
0
]
.
op
,
tensor
.
Elemwise
)
assert
isinstance
(
fgraph
.
toposort
()[
0
]
.
op
,
tensor
.
Elemwise
)
assert
isinstance
(
fgraph
.
toposort
()[
1
]
.
op
,
Softmax
)
assert
isinstance
(
fgraph
.
toposort
()[
1
]
.
op
,
Softmax
)
assert
isinstance
(
fgraph
.
toposort
()[
2
]
.
op
,
tensor
.
CAReduce
)
assert
isinstance
(
fgraph
.
toposort
()[
2
]
.
op
,
tensor
.
CAReduce
)
...
...
theano/tensor/signal/tests/test_downsample.py
浏览文件 @
3089deda
...
@@ -245,8 +245,8 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
...
@@ -245,8 +245,8 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
stridesizes
=
[(
2
,
2
),
(
2
,
2
),
(
1
,
1
),
(
1
,
2
),
(
2
,
2
)]
stridesizes
=
[(
2
,
2
),
(
2
,
2
),
(
1
,
1
),
(
1
,
2
),
(
2
,
2
)]
paddingsizes
=
[(
2
,
2
),
(
1
,
2
),
(
2
,
1
),
(
0
,
0
),
(
1
,
1
)]
paddingsizes
=
[(
2
,
2
),
(
1
,
2
),
(
2
,
1
),
(
0
,
0
),
(
1
,
1
)]
imgsizes
=
[(
5
,
5
),
(
5
,
5
),
(
5
,
6
),
(
6
,
5
),
(
5
,
5
)]
imgsizes
=
[(
5
,
5
),
(
5
,
5
),
(
5
,
6
),
(
6
,
5
),
(
5
,
5
)]
m
=
4
# minibatch
m
=
4
# minibatch
c
=
10
# channel size
c
=
10
# channel size
images
=
tensor
.
dtensor4
()
images
=
tensor
.
dtensor4
()
for
indx
in
numpy
.
arange
(
len
(
maxpoolsizes
)):
for
indx
in
numpy
.
arange
(
len
(
maxpoolsizes
)):
imgsize
=
imgsizes
[
indx
]
imgsize
=
imgsizes
[
indx
]
...
...
theano/tensor/tests/mlp_test.py
浏览文件 @
3089deda
...
@@ -269,7 +269,7 @@ def test_mlp():
...
@@ -269,7 +269,7 @@ def test_mlp():
# allocate symbolic variables for the data
# allocate symbolic variables for the data
index
=
T
.
lscalar
()
# index to a [mini]batch
index
=
T
.
lscalar
()
# index to a [mini]batch
x
=
T
.
matrix
(
'x'
)
# the data is presented as rasterized images
x
=
T
.
matrix
(
'x'
)
# the data is presented as rasterized images
y
=
T
.
ivector
(
'y'
)
# the labels are presented as 1D vector of
y
=
T
.
ivector
(
'y'
)
# the labels are presented as 1D vector of
# [int] labels
# [int] labels
rng
=
numpy
.
random
.
RandomState
(
1234
)
rng
=
numpy
.
random
.
RandomState
(
1234
)
...
...
theano/tensor/tests/test_blas_scipy.py
浏览文件 @
3089deda
...
@@ -43,19 +43,19 @@ class TestScipyGer(TestCase, TestOptimizationMixin):
...
@@ -43,19 +43,19 @@ class TestScipyGer(TestCase, TestOptimizationMixin):
f
=
self
.
function
([
self
.
A
,
self
.
x
,
self
.
y
],
f
=
self
.
function
([
self
.
A
,
self
.
x
,
self
.
y
],
self
.
A
+
tensor
.
outer
(
self
.
x
,
self
.
y
))
self
.
A
+
tensor
.
outer
(
self
.
x
,
self
.
y
))
self
.
assertFunctionContains
(
f
,
ScipyGer
(
destructive
=
False
))
self
.
assertFunctionContains
(
f
,
ScipyGer
(
destructive
=
False
))
self
.
run_f
(
f
)
#
DebugMode tests correctness
self
.
run_f
(
f
)
#
DebugMode tests correctness
def
test_A_plus_scaled_outer
(
self
):
def
test_A_plus_scaled_outer
(
self
):
f
=
self
.
function
([
self
.
A
,
self
.
x
,
self
.
y
],
f
=
self
.
function
([
self
.
A
,
self
.
x
,
self
.
y
],
self
.
A
+
0.1
*
tensor
.
outer
(
self
.
x
,
self
.
y
))
self
.
A
+
0.1
*
tensor
.
outer
(
self
.
x
,
self
.
y
))
self
.
assertFunctionContains
(
f
,
ScipyGer
(
destructive
=
False
))
self
.
assertFunctionContains
(
f
,
ScipyGer
(
destructive
=
False
))
self
.
run_f
(
f
)
#
DebugMode tests correctness
self
.
run_f
(
f
)
#
DebugMode tests correctness
def
test_scaled_A_plus_scaled_outer
(
self
):
def
test_scaled_A_plus_scaled_outer
(
self
):
f
=
self
.
function
([
self
.
A
,
self
.
x
,
self
.
y
],
f
=
self
.
function
([
self
.
A
,
self
.
x
,
self
.
y
],
0.2
*
self
.
A
+
0.1
*
tensor
.
outer
(
self
.
x
,
self
.
y
))
0.2
*
self
.
A
+
0.1
*
tensor
.
outer
(
self
.
x
,
self
.
y
))
self
.
assertFunctionContains
(
f
,
gemm_no_inplace
)
self
.
assertFunctionContains
(
f
,
gemm_no_inplace
)
self
.
run_f
(
f
)
#
DebugMode tests correctness
self
.
run_f
(
f
)
#
DebugMode tests correctness
class
TestBlasStridesScipy
(
TestBlasStrides
):
class
TestBlasStridesScipy
(
TestBlasStrides
):
mode
=
theano
.
compile
.
get_default_mode
()
mode
=
theano
.
compile
.
get_default_mode
()
...
...
theano/tensor/tests/test_mpi.py
浏览文件 @
3089deda
...
@@ -53,8 +53,8 @@ def test_mpi_send_wait_cmp():
...
@@ -53,8 +53,8 @@ def test_mpi_send_wait_cmp():
waitnode
=
y
.
owner
waitnode
=
y
.
owner
sendnode
=
y
.
owner
.
inputs
[
0
]
.
owner
sendnode
=
y
.
owner
.
inputs
[
0
]
.
owner
addnode
=
z
.
owner
addnode
=
z
.
owner
assert
mpi_send_wait_cmp
(
sendnode
,
addnode
)
<
0
# send happens first
assert
mpi_send_wait_cmp
(
sendnode
,
addnode
)
<
0
# send happens first
assert
mpi_send_wait_cmp
(
waitnode
,
addnode
)
>
0
# wait happens last
assert
mpi_send_wait_cmp
(
waitnode
,
addnode
)
>
0
# wait happens last
def
test_mpi_tag_ordering
():
def
test_mpi_tag_ordering
():
x
=
recv
((
2
,
2
),
'float32'
,
1
,
12
)
x
=
recv
((
2
,
2
),
'float32'
,
1
,
12
)
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
3089deda
...
@@ -983,12 +983,12 @@ class test_fusion(unittest.TestCase):
...
@@ -983,12 +983,12 @@ class test_fusion(unittest.TestCase):
(
fx
-
theano
.
tensor
.
true_div
(
fy
,
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
(
fx
-
theano
.
tensor
.
true_div
(
fy
,
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
(
fyv
/
fzv
),
'float32'
),
fyv
,
fzv
),
1
,
fxv
-
(
fyv
/
fzv
),
'float32'
),
(
fx
-
theano
.
tensor
.
int_div
(
ix
*
100
,
iy
*
1000
),
(
fx
,
ix
,
(
fx
-
theano
.
tensor
.
int_div
(
ix
*
100
,
iy
*
1000
),
(
fx
,
ix
,
iy
),
(
fxv
,
ixv
,
iyv
),
1
,
fxv
-
((
ixv
*
100
)
//
(
iyv
*
1000
)),
{
'custom'
:
'float64'
,
'numpy+floatX'
:
config
.
floatX
,
'numpy'
:
'float64'
}),
#
40
iy
),
(
fxv
,
ixv
,
iyv
),
1
,
fxv
-
((
ixv
*
100
)
//
(
iyv
*
1000
)),
{
'custom'
:
'float64'
,
'numpy+floatX'
:
config
.
floatX
,
'numpy'
:
'float64'
}),
#
40
(
fx
-
(
fy
/
2
),
(
fx
,
fy
),
(
fxv
,
fyv
),
1
,
fxv
-
(
fyv
/
2
),
'float32'
),
(
fx
-
(
fy
/
2
),
(
fx
,
fy
),
(
fxv
,
fyv
),
1
,
fxv
-
(
fyv
/
2
),
'float32'
),
(
fx
-
(
fy
%
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
(
fyv
%
fzv
),
'float32'
),
(
fx
-
(
fy
%
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
(
fyv
%
fzv
),
'float32'
),
(
fx
-
(
fy
>
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
(
fyv
>
fzv
),
'float32'
),
(
fx
-
(
fy
>
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
(
fyv
>
fzv
),
'float32'
),
(
fx
-
(
fy
>=
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
(
fyv
>=
fzv
),
'float32'
),
(
fx
-
(
fy
>=
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
(
fyv
>=
fzv
),
'float32'
),
(
fx
-
(
fy
<
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
(
fyv
<
fzv
),
'float32'
),
#
45
(
fx
-
(
fy
<
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
(
fyv
<
fzv
),
'float32'
),
#
45
(
fx
-
(
fy
<=
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
(
fyv
<=
fzv
),
'float32'
),
(
fx
-
(
fy
<=
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
(
fyv
<=
fzv
),
'float32'
),
(
fx
-
T
.
eq
(
fy
,
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
(
(
fx
-
T
.
eq
(
fy
,
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
(
fyv
==
fzv
),
'float32'
),
fyv
==
fzv
),
'float32'
),
...
@@ -997,7 +997,7 @@ class test_fusion(unittest.TestCase):
...
@@ -997,7 +997,7 @@ class test_fusion(unittest.TestCase):
(
fx
-
fy
+
tensor
.
tan
(
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
(
fx
-
fy
+
tensor
.
tan
(
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
fyv
+
numpy
.
tan
(
fzv
),
'float32'
),
fxv
-
fyv
+
numpy
.
tan
(
fzv
),
'float32'
),
(
fx
-
fy
+
tensor
.
tanh
(
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
(
fx
-
fy
+
tensor
.
tanh
(
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
fyv
+
numpy
.
tanh
(
fzv
),
'float32'
),
#
50
fxv
-
fyv
+
numpy
.
tanh
(
fzv
),
'float32'
),
#
50
(
fx
-
fy
+
tensor
.
sin
(
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
(
fx
-
fy
+
tensor
.
sin
(
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
fyv
+
numpy
.
sin
(
fzv
),
'float32'
),
fxv
-
fyv
+
numpy
.
sin
(
fzv
),
'float32'
),
(
fx
-
fy
+
tensor
.
sinh
(
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
(
fx
-
fy
+
tensor
.
sinh
(
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
...
@@ -1007,7 +1007,7 @@ class test_fusion(unittest.TestCase):
...
@@ -1007,7 +1007,7 @@ class test_fusion(unittest.TestCase):
(
fx
-
fy
+
theano
.
tensor
.
sqrt
(
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
(
fx
-
fy
+
theano
.
tensor
.
sqrt
(
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
fyv
+
numpy
.
sqrt
(
fzv
),
'float32'
),
fzv
),
1
,
fxv
-
fyv
+
numpy
.
sqrt
(
fzv
),
'float32'
),
(
fx
-
fy
+
theano
.
tensor
.
inv
(
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
(
fx
-
fy
+
theano
.
tensor
.
inv
(
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
fyv
+
(
1
/
fzv
),
'float32'
),
#
55
fzv
),
1
,
fxv
-
fyv
+
(
1
/
fzv
),
'float32'
),
#
55
(
fx
-
fy
+
theano
.
tensor
.
neg
(
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
(
fx
-
fy
+
theano
.
tensor
.
neg
(
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
fxv
-
fyv
+
(
-
fzv
),
'float32'
),
fzv
),
1
,
fxv
-
fyv
+
(
-
fzv
),
'float32'
),
(
fx
-
fy
+
theano
.
tensor
.
round
(
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
(
fx
-
fy
+
theano
.
tensor
.
round
(
fz
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
...
@@ -1018,7 +1018,7 @@ class test_fusion(unittest.TestCase):
...
@@ -1018,7 +1018,7 @@ class test_fusion(unittest.TestCase):
(
fx
-
theano
.
tensor
.
or_
(
iy
,
iz
),
(
fx
,
iy
,
iz
),
(
fxv
,
iyv
,
(
fx
-
theano
.
tensor
.
or_
(
iy
,
iz
),
(
fx
,
iy
,
iz
),
(
fxv
,
iyv
,
izv
),
1
,
fxv
-
(
iyv
|
izv
),
{
'custom'
:
'float64'
,
'numpy+floatX'
:
config
.
floatX
,
'numpy'
:
'float64'
}),
izv
),
1
,
fxv
-
(
iyv
|
izv
),
{
'custom'
:
'float64'
,
'numpy+floatX'
:
config
.
floatX
,
'numpy'
:
'float64'
}),
(
fx
-
theano
.
tensor
.
xor
(
iy
,
iz
),
(
fx
,
iy
,
iz
),
(
fxv
,
iyv
,
(
fx
-
theano
.
tensor
.
xor
(
iy
,
iz
),
(
fx
,
iy
,
iz
),
(
fxv
,
iyv
,
izv
),
1
,
fxv
-
(
iyv
^
izv
),
{
'custom'
:
'float64'
,
'numpy+floatX'
:
config
.
floatX
,
'numpy'
:
'float64'
}),
#
60
izv
),
1
,
fxv
-
(
iyv
^
izv
),
{
'custom'
:
'float64'
,
'numpy+floatX'
:
config
.
floatX
,
'numpy'
:
'float64'
}),
#
60
(
fx
-
theano
.
tensor
.
and_
(
iy
,
iz
),
(
fx
,
iy
,
iz
),
(
fxv
,
iyv
,
(
fx
-
theano
.
tensor
.
and_
(
iy
,
iz
),
(
fx
,
iy
,
iz
),
(
fxv
,
iyv
,
izv
),
1
,
fxv
-
(
iyv
&
izv
),
{
'custom'
:
'float64'
,
'numpy+floatX'
:
config
.
floatX
,
'numpy'
:
'float64'
}),
izv
),
1
,
fxv
-
(
iyv
&
izv
),
{
'custom'
:
'float64'
,
'numpy+floatX'
:
config
.
floatX
,
'numpy'
:
'float64'
}),
(
fx
-
theano
.
tensor
.
invert
(
iy
),
(
fx
,
iy
),
(
fxv
,
iyv
),
1
,
(
fx
-
theano
.
tensor
.
invert
(
iy
),
(
fx
,
iy
),
(
fxv
,
iyv
),
1
,
...
@@ -1029,9 +1029,9 @@ class test_fusion(unittest.TestCase):
...
@@ -1029,9 +1029,9 @@ class test_fusion(unittest.TestCase):
(
theano
.
tensor
.
pow
(
fx
*
fy
+
fz
,
fx
*
fy
),
(
fx
,
fy
,
fz
),
(
fxv
,
(
theano
.
tensor
.
pow
(
fx
*
fy
+
fz
,
fx
*
fy
),
(
fx
,
fy
,
fz
),
(
fxv
,
fyv
,
fzv
),
1
,
numpy
.
power
(
fxv
*
fyv
+
fzv
,
fxv
*
fyv
),
'float32'
),
fyv
,
fzv
),
1
,
numpy
.
power
(
fxv
*
fyv
+
fzv
,
fxv
*
fyv
),
'float32'
),
(
fv
+
fy
**
fz
,
(
fv
,
fy
,
fz
),
(
fvv
,
fyv
,
fzv
),
2
,
fvv
+
fyv
**
fzv
,
(
fv
+
fy
**
fz
,
(
fv
,
fy
,
fz
),
(
fvv
,
fyv
,
fzv
),
2
,
fvv
+
fyv
**
fzv
,
'float32'
),
#
fused with a dimshuffle #65
'float32'
),
#
fused with a dimshuffle #65
(
fv
-
fy
+
tensor
.
tanh
(
fz
),
(
fv
,
fy
,
fz
),
(
fvv
,
fyv
,
fzv
),
2
,
(
fv
-
fy
+
tensor
.
tanh
(
fz
),
(
fv
,
fy
,
fz
),
(
fvv
,
fyv
,
fzv
),
2
,
fvv
-
fyv
+
numpy
.
tanh
(
fzv
),
'float32'
),
#
fused with a dimshuffle
fvv
-
fyv
+
numpy
.
tanh
(
fzv
),
'float32'
),
#
fused with a dimshuffle
# Cases where the same input is reused many times.
# Cases where the same input is reused many times.
(
theano
.
tensor
.
mul
(
fx
,
fx
,
fx
,
fx
),
(
fx
,),
(
fxv
,),
1
,
fxv
*
(
theano
.
tensor
.
mul
(
fx
,
fx
,
fx
,
fx
),
(
fx
,),
(
fxv
,),
1
,
fxv
*
...
@@ -1041,7 +1041,7 @@ class test_fusion(unittest.TestCase):
...
@@ -1041,7 +1041,7 @@ class test_fusion(unittest.TestCase):
(
theano
.
tensor
.
mul
(
fx
,
ftanx
,
ftanx
,
fx
),
(
fx
,),
(
fxv
,),
(
theano
.
tensor
.
mul
(
fx
,
ftanx
,
ftanx
,
fx
),
(
fx
,),
(
fxv
,),
1
,
fxv
*
numpy
.
tan
(
fxv
)
*
numpy
.
tan
(
fxv
)
*
fxv
,
'float32'
),
1
,
fxv
*
numpy
.
tan
(
fxv
)
*
numpy
.
tan
(
fxv
)
*
fxv
,
'float32'
),
(
theano
.
tensor
.
mul
(
ftanx
,
ftanx
,
fx
+
fy
),
(
fx
,
fy
),
(
fxv
,
(
theano
.
tensor
.
mul
(
ftanx
,
ftanx
,
fx
+
fy
),
(
fx
,
fy
),
(
fxv
,
fyv
),
1
,
numpy
.
tan
(
fxv
)
*
numpy
.
tan
(
fxv
)
*
(
fxv
+
fyv
),
'float32'
),
# 70
fyv
),
1
,
numpy
.
tan
(
fxv
)
*
numpy
.
tan
(
fxv
)
*
(
fxv
+
fyv
),
'float32'
),
# 70
# Cases with different broadcast pattern. They should not
# Cases with different broadcast pattern. They should not
# be merged as this would duplicate computation
# be merged as this would duplicate computation
...
...
theano/tensor/tests/test_shared_randomstreams.py
浏览文件 @
3089deda
...
@@ -43,7 +43,7 @@ class T_SharedRandomStreams(unittest.TestCase):
...
@@ -43,7 +43,7 @@ class T_SharedRandomStreams(unittest.TestCase):
gn_val0
=
gn
()
gn_val0
=
gn
()
rng_seed
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
.
randint
(
2
**
30
)
rng_seed
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
.
randint
(
2
**
30
)
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#
int() is for 32bit
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#
int() is for 32bit
# print fn_val0
# print fn_val0
numpy_val0
=
rng
.
uniform
(
size
=
(
2
,
2
))
numpy_val0
=
rng
.
uniform
(
size
=
(
2
,
2
))
...
@@ -86,7 +86,7 @@ class T_SharedRandomStreams(unittest.TestCase):
...
@@ -86,7 +86,7 @@ class T_SharedRandomStreams(unittest.TestCase):
random
.
seed
(
utt
.
fetch_seed
())
random
.
seed
(
utt
.
fetch_seed
())
rng
=
numpy
.
random
.
RandomState
()
rng
=
numpy
.
random
.
RandomState
()
rng
.
set_state
(
random
[
out
.
rng
]
.
get_state
())
#
tests getitem
rng
.
set_state
(
random
[
out
.
rng
]
.
get_state
())
#
tests getitem
fn_val0
=
fn
()
fn_val0
=
fn
()
fn_val1
=
fn
()
fn_val1
=
fn
()
...
@@ -143,7 +143,7 @@ class T_SharedRandomStreams(unittest.TestCase):
...
@@ -143,7 +143,7 @@ class T_SharedRandomStreams(unittest.TestCase):
fn_val1
=
fn
()
fn_val1
=
fn
()
rng_seed
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
.
randint
(
2
**
30
)
rng_seed
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
.
randint
(
2
**
30
)
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#
int() is for 32bit
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#
int() is for 32bit
numpy_val0
=
rng
.
uniform
(
-
1
,
1
,
size
=
(
2
,
2
))
numpy_val0
=
rng
.
uniform
(
-
1
,
1
,
size
=
(
2
,
2
))
numpy_val1
=
rng
.
uniform
(
-
1
,
1
,
size
=
(
2
,
2
))
numpy_val1
=
rng
.
uniform
(
-
1
,
1
,
size
=
(
2
,
2
))
...
@@ -160,7 +160,7 @@ class T_SharedRandomStreams(unittest.TestCase):
...
@@ -160,7 +160,7 @@ class T_SharedRandomStreams(unittest.TestCase):
fn_val1
=
fn
()
fn_val1
=
fn
()
rng_seed
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
.
randint
(
2
**
30
)
rng_seed
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
.
randint
(
2
**
30
)
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#
int() is for 32bit
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#
int() is for 32bit
numpy_val0
=
rng
.
normal
(
-
1
,
2
,
size
=
(
2
,
2
))
numpy_val0
=
rng
.
normal
(
-
1
,
2
,
size
=
(
2
,
2
))
numpy_val1
=
rng
.
normal
(
-
1
,
2
,
size
=
(
2
,
2
))
numpy_val1
=
rng
.
normal
(
-
1
,
2
,
size
=
(
2
,
2
))
...
@@ -176,7 +176,7 @@ class T_SharedRandomStreams(unittest.TestCase):
...
@@ -176,7 +176,7 @@ class T_SharedRandomStreams(unittest.TestCase):
fn_val1
=
fn
()
fn_val1
=
fn
()
rng_seed
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
.
randint
(
2
**
30
)
rng_seed
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
.
randint
(
2
**
30
)
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#
int() is for 32bit
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#
int() is for 32bit
numpy_val0
=
rng
.
random_integers
(
-
5
,
5
,
size
=
(
20
,
20
))
numpy_val0
=
rng
.
random_integers
(
-
5
,
5
,
size
=
(
20
,
20
))
numpy_val1
=
rng
.
random_integers
(
-
5
,
5
,
size
=
(
20
,
20
))
numpy_val1
=
rng
.
random_integers
(
-
5
,
5
,
size
=
(
20
,
20
))
...
@@ -198,7 +198,7 @@ class T_SharedRandomStreams(unittest.TestCase):
...
@@ -198,7 +198,7 @@ class T_SharedRandomStreams(unittest.TestCase):
fn_val1
=
fn
()
fn_val1
=
fn
()
rng_seed
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
.
randint
(
2
**
30
)
rng_seed
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
.
randint
(
2
**
30
)
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#
int() is for 32bit
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#
int() is for 32bit
numpy_val0
=
rng
.
choice
(
10
,
(
11
,
8
),
True
,
None
)
numpy_val0
=
rng
.
choice
(
10
,
(
11
,
8
),
True
,
None
)
numpy_val1
=
rng
.
choice
(
10
,
(
11
,
8
),
True
,
None
)
numpy_val1
=
rng
.
choice
(
10
,
(
11
,
8
),
True
,
None
)
...
@@ -215,7 +215,7 @@ class T_SharedRandomStreams(unittest.TestCase):
...
@@ -215,7 +215,7 @@ class T_SharedRandomStreams(unittest.TestCase):
fn_val1
=
fn
()
fn_val1
=
fn
()
rng_seed
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
.
randint
(
2
**
30
)
rng_seed
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
.
randint
(
2
**
30
)
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#
int() is for 32bit
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#
int() is for 32bit
numpy_val0
=
rng
.
poisson
(
lam
=
5
,
size
=
(
11
,
8
))
numpy_val0
=
rng
.
poisson
(
lam
=
5
,
size
=
(
11
,
8
))
numpy_val1
=
rng
.
poisson
(
lam
=
5
,
size
=
(
11
,
8
))
numpy_val1
=
rng
.
poisson
(
lam
=
5
,
size
=
(
11
,
8
))
...
@@ -232,7 +232,7 @@ class T_SharedRandomStreams(unittest.TestCase):
...
@@ -232,7 +232,7 @@ class T_SharedRandomStreams(unittest.TestCase):
fn_val1
=
fn
()
fn_val1
=
fn
()
rng_seed
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
.
randint
(
2
**
30
)
rng_seed
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
.
randint
(
2
**
30
)
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#
int() is for 32bit
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#
int() is for 32bit
# rng.permutation outputs one vector at a time, so we iterate.
# rng.permutation outputs one vector at a time, so we iterate.
numpy_val0
=
numpy
.
asarray
([
rng
.
permutation
(
10
)
for
i
in
range
(
20
)])
numpy_val0
=
numpy
.
asarray
([
rng
.
permutation
(
10
)
for
i
in
range
(
20
)])
...
@@ -251,7 +251,7 @@ class T_SharedRandomStreams(unittest.TestCase):
...
@@ -251,7 +251,7 @@ class T_SharedRandomStreams(unittest.TestCase):
fn_val1
=
fn
()
fn_val1
=
fn
()
rng_seed
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
.
randint
(
2
**
30
)
rng_seed
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
.
randint
(
2
**
30
)
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#
int() is for 32bit
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#
int() is for 32bit
numpy_val0
=
rng
.
multinomial
(
1
,
[
0.1
]
*
10
,
size
=
(
4
,
4
))
numpy_val0
=
rng
.
multinomial
(
1
,
[
0.1
]
*
10
,
size
=
(
4
,
4
))
numpy_val1
=
rng
.
multinomial
(
1
,
[
0.1
]
*
10
,
size
=
(
4
,
4
))
numpy_val1
=
rng
.
multinomial
(
1
,
[
0.1
]
*
10
,
size
=
(
4
,
4
))
...
@@ -419,7 +419,7 @@ class T_SharedRandomStreams(unittest.TestCase):
...
@@ -419,7 +419,7 @@ class T_SharedRandomStreams(unittest.TestCase):
assert
numpy
.
allclose
(
val0
,
numpy_val0
)
assert
numpy
.
allclose
(
val0
,
numpy_val0
)
assert
numpy
.
allclose
(
val1
,
numpy_val1
)
assert
numpy
.
allclose
(
val1
,
numpy_val1
)
for
i
in
range
(
10
):
# every test has 50% chance of passing even with non-matching random states
for
i
in
range
(
10
):
# every test has 50% chance of passing even with non-matching random states
val2
=
g
()
val2
=
g
()
numpy_val2
=
multinomial_rng
.
multinomial
(
n
=
1
,
pvals
=
[
.
5
,
.
5
])
numpy_val2
=
multinomial_rng
.
multinomial
(
n
=
1
,
pvals
=
[
.
5
,
.
5
])
assert
numpy
.
all
(
val2
==
numpy_val2
)
assert
numpy
.
all
(
val2
==
numpy_val2
)
...
...
theano/tensor/tests/test_sharedvar.py
浏览文件 @
3089deda
...
@@ -97,7 +97,7 @@ def makeSharedTester(shared_constructor_,
...
@@ -97,7 +97,7 @@ def makeSharedTester(shared_constructor_,
values_to_div
=
.
5
values_to_div
=
.
5
if
self
.
op_by_matrix
:
if
self
.
op_by_matrix
:
values_to_div
=
self
.
internal_type
(
numpy
.
ones
(
x
.
shape
,
dtype
=
dtype
)
/
2
)
#
supported for cudandarray, but not ndarray.
values_to_div
=
self
.
internal_type
(
numpy
.
ones
(
x
.
shape
,
dtype
=
dtype
)
/
2
)
#
supported for cudandarray, but not ndarray.
assert
self
.
test_internal_type
(
values_to_div
)
assert
self
.
test_internal_type
(
values_to_div
)
x
/=
values_to_div
x
/=
values_to_div
total_val_2
=
total_func
()
total_val_2
=
total_func
()
...
@@ -193,7 +193,7 @@ def makeSharedTester(shared_constructor_,
...
@@ -193,7 +193,7 @@ def makeSharedTester(shared_constructor_,
# supported for cudandarray, but not ndarray.
# supported for cudandarray, but not ndarray.
values_to_div
=
self
.
internal_type
(
values_to_div
=
self
.
internal_type
(
numpy
.
ones
(
x
.
shape
,
dtype
=
dtype
)
/
2
)
numpy
.
ones
(
x
.
shape
,
dtype
=
dtype
)
/
2
)
x
/=
values_to_div
#
supported by ndarray and CudaNdarray
x
/=
values_to_div
#
supported by ndarray and CudaNdarray
# this is not required by the contract but it is a feature we can
# this is not required by the contract but it is a feature we can
# implement for some type of SharedVariable.
# implement for some type of SharedVariable.
...
@@ -202,7 +202,7 @@ def makeSharedTester(shared_constructor_,
...
@@ -202,7 +202,7 @@ def makeSharedTester(shared_constructor_,
x
=
x_shared
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
x
=
x_shared
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
assert
self
.
test_internal_type
(
x
)
assert
self
.
test_internal_type
(
x
)
assert
x
is
not
x_shared
.
container
.
value
assert
x
is
not
x_shared
.
container
.
value
x
/=
values_to_div
#
supported by ndarray and CudaNdarray
x
/=
values_to_div
#
supported by ndarray and CudaNdarray
# this is required by the contract
# this is required by the contract
assert
not
numpy
.
allclose
(
self
.
ref_fct
(
x
),
total_func
())
assert
not
numpy
.
allclose
(
self
.
ref_fct
(
x
),
total_func
())
...
@@ -251,7 +251,7 @@ def makeSharedTester(shared_constructor_,
...
@@ -251,7 +251,7 @@ def makeSharedTester(shared_constructor_,
# test if that theano shared variable optimize set_value(borrow=True)
# test if that theano shared variable optimize set_value(borrow=True)
get_x
=
x_shared
.
get_value
(
borrow
=
True
)
get_x
=
x_shared
.
get_value
(
borrow
=
True
)
assert
get_x
is
not
x_orig
#
borrow=False to shared_constructor
assert
get_x
is
not
x_orig
#
borrow=False to shared_constructor
get_x
/=
values_to_div
get_x
/=
values_to_div
x_shared
.
set_value
(
get_x
,
borrow
=
True
)
x_shared
.
set_value
(
get_x
,
borrow
=
True
)
x
=
x_shared
.
get_value
(
borrow
=
True
)
x
=
x_shared
.
get_value
(
borrow
=
True
)
...
@@ -263,10 +263,10 @@ def makeSharedTester(shared_constructor_,
...
@@ -263,10 +263,10 @@ def makeSharedTester(shared_constructor_,
# test optimized get set value on the gpu(don't pass data to the cpu)
# test optimized get set value on the gpu(don't pass data to the cpu)
get_x
=
x_shared
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)
get_x
=
x_shared
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)
assert
get_x
is
not
x_orig
#
borrow=False to shared_constructor
assert
get_x
is
not
x_orig
#
borrow=False to shared_constructor
assert
self
.
test_internal_type
(
get_x
)
assert
self
.
test_internal_type
(
get_x
)
get_x
/=
values_to_div
#
supported by ndarray and CudaNdarray
get_x
/=
values_to_div
#
supported by ndarray and CudaNdarray
assert
self
.
test_internal_type
(
get_x
)
assert
self
.
test_internal_type
(
get_x
)
x_shared
.
set_value
(
get_x
,
borrow
=
True
)
x_shared
.
set_value
(
get_x
,
borrow
=
True
)
x
=
x_shared
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)
x
=
x_shared
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)
...
@@ -316,7 +316,7 @@ def makeSharedTester(shared_constructor_,
...
@@ -316,7 +316,7 @@ def makeSharedTester(shared_constructor_,
if
dtype
is
None
:
if
dtype
is
None
:
dtype
=
theano
.
config
.
floatX
dtype
=
theano
.
config
.
floatX
shp
=
(
100
/
4
,
1024
)
#
100KB
shp
=
(
100
/
4
,
1024
)
#
100KB
x
=
numpy
.
zeros
(
shp
,
dtype
=
dtype
)
x
=
numpy
.
zeros
(
shp
,
dtype
=
dtype
)
x
=
self
.
cast_value
(
x
)
x
=
self
.
cast_value
(
x
)
...
...
theano/tests/test_tutorial.py
浏览文件 @
3089deda
...
@@ -461,7 +461,7 @@ class T_extending(unittest.TestCase):
...
@@ -461,7 +461,7 @@ class T_extending(unittest.TestCase):
# This should be needed for the EquilibriumOptimizer
# This should be needed for the EquilibriumOptimizer
# but it isn't now
# but it isn't now
# TODO: do this and explain it
# TODO: do this and explain it
return
[]
# that's not what you should do
return
[]
# that's not what you should do
local_simplify
=
LocalSimplify
()
local_simplify
=
LocalSimplify
()
...
@@ -775,8 +775,8 @@ class T_examples(unittest.TestCase):
...
@@ -775,8 +775,8 @@ class T_examples(unittest.TestCase):
# Construct Theano expression graph
# Construct Theano expression graph
p_1
=
1
/
(
1
+
T
.
exp
(
-
T
.
dot
(
x
,
w
)
-
b
))
# Probability that target = 1
p_1
=
1
/
(
1
+
T
.
exp
(
-
T
.
dot
(
x
,
w
)
-
b
))
# Probability that target = 1
prediction
=
p_1
>
0.5
# The prediction thresholded
prediction
=
p_1
>
0.5
# The prediction thresholded
xent
=
-
y
*
T
.
log
(
p_1
)
-
(
1
-
y
)
*
T
.
log
(
1
-
p_1
)
# Cross-entropy loss function
xent
=
-
y
*
T
.
log
(
p_1
)
-
(
1
-
y
)
*
T
.
log
(
1
-
p_1
)
# Cross-entropy loss function
cost
=
xent
.
mean
()
+
0.01
*
(
w
**
2
)
.
sum
()
# The cost to minimize
cost
=
xent
.
mean
()
+
0.01
*
(
w
**
2
)
.
sum
()
# The cost to minimize
gw
,
gb
=
T
.
grad
(
cost
,
[
w
,
b
])
# Compute the gradient of the cost
gw
,
gb
=
T
.
grad
(
cost
,
[
w
,
b
])
# Compute the gradient of the cost
# (we shall return to this in a
# (we shall return to this in a
# following section of this tutorial)
# following section of this tutorial)
...
@@ -817,7 +817,7 @@ class T_aliasing(unittest.TestCase):
...
@@ -817,7 +817,7 @@ class T_aliasing(unittest.TestCase):
s_false
=
theano
.
shared
(
np_array
,
borrow
=
False
)
s_false
=
theano
.
shared
(
np_array
,
borrow
=
False
)
s_true
=
theano
.
shared
(
np_array
,
borrow
=
True
)
s_true
=
theano
.
shared
(
np_array
,
borrow
=
True
)
np_array
+=
1
# now it is an array of 2.0 s
np_array
+=
1
# now it is an array of 2.0 s
assert
numpy
.
all
(
s_default
.
get_value
()
==
array
([
1.0
,
1.0
]))
assert
numpy
.
all
(
s_default
.
get_value
()
==
array
([
1.0
,
1.0
]))
assert
numpy
.
all
(
s_false
.
get_value
()
==
array
([
1.0
,
1.0
]))
assert
numpy
.
all
(
s_false
.
get_value
()
==
array
([
1.0
,
1.0
]))
...
@@ -831,7 +831,7 @@ class T_aliasing(unittest.TestCase):
...
@@ -831,7 +831,7 @@ class T_aliasing(unittest.TestCase):
s
=
theano
.
shared
(
np_array
)
s
=
theano
.
shared
(
np_array
)
v_false
=
s
.
get_value
(
borrow
=
False
)
# N.B. borrow default is False
v_false
=
s
.
get_value
(
borrow
=
False
)
# N.B. borrow default is False
v_true
=
s
.
get_value
(
borrow
=
True
)
v_true
=
s
.
get_value
(
borrow
=
True
)
v_internal
=
s
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)
v_internal
=
s
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论