Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
14ceb214
提交
14ceb214
authored
2月 01, 2010
作者:
gdesjardins
浏览文件
操作
浏览文件
下载
差异文件
merge
上级
0923873d
a7dbed9c
隐藏空白字符变更
内嵌
并排
正在显示
17 个修改的文件
包含
63 行增加
和
52 行删除
+63
-52
unittest.txt
doc/extending/unittest.txt
+2
-2
mode.txt
doc/library/compile/mode.txt
+1
-2
debugging_with_stepmode.txt
doc/sandbox/debugging_with_stepmode.txt
+3
-2
modes.txt
doc/tutorial/modes.txt
+2
-3
function_module.py
theano/compile/function_module.py
+2
-2
mode.py
theano/compile/mode.py
+7
-12
module.py
theano/compile/module.py
+3
-3
profilemode.py
theano/compile/profilemode.py
+2
-2
test_function_module.py
theano/compile/tests/test_function_module.py
+12
-6
test_misc.py
theano/compile/tests/test_misc.py
+0
-1
test_module.py
theano/compile/tests/test_module.py
+4
-4
test_pfunc.py
theano/compile/tests/test_pfunc.py
+1
-1
configdefaults.py
theano/configdefaults.py
+12
-1
test_conv.py
theano/tensor/nnet/tests/test_conv.py
+2
-1
test_basic.py
theano/tensor/tests/test_basic.py
+2
-2
test_naacl09.py
theano/tensor/tests/test_naacl09.py
+2
-2
test_opt.py
theano/tensor/tests/test_opt.py
+6
-6
没有找到文件。
doc/extending/unittest.txt
浏览文件 @
14ceb214
...
@@ -261,8 +261,8 @@ Example:
...
@@ -261,8 +261,8 @@ Example:
>>> minstance = m.make(mode='DEBUG_MODE')
>>> minstance = m.make(mode='DEBUG_MODE')
Whenever possible, unit tests should omit this parameter. Leaving
Whenever possible, unit tests should omit this parameter. Leaving
out the mode will ensure that unit tests use the default mode
out the mode will ensure that unit tests use the default mode
.
(defined in compile.mode.default_mode). This default_
mode is set to
This default
mode is set to
the configuration variable :attr:`config.mode`, which defaults to
the configuration variable :attr:`config.mode`, which defaults to
'FAST_RUN', and can be set by various mechanisms (see :mod:`config`).
'FAST_RUN', and can be set by various mechanisms (see :mod:`config`).
...
...
doc/library/compile/mode.txt
浏览文件 @
14ceb214
...
@@ -22,8 +22,7 @@ Theano defines the following modes by name:
...
@@ -22,8 +22,7 @@ Theano defines the following modes by name:
but can identify many kinds of problems.
but can identify many kinds of problems.
The default mode is typically ``FAST_RUN``, but it can be controlled via the
The default mode is typically ``FAST_RUN``, but it can be controlled via the
configuration variable :attr:`config.mode`, which can in turn be overridden by
configuration variable :attr:`config.mode`, which can be
setting ``theano.compile.mode.default_mode`` directly, which can in turn be
overridden by passing the keyword argument to :func:`theano.function`.
overridden by passing the keyword argument to :func:`theano.function`.
.. TODO::
.. TODO::
...
...
doc/sandbox/debugging_with_stepmode.txt
浏览文件 @
14ceb214
...
@@ -10,11 +10,12 @@ purpose of it is to hack it to investigate what your own particular program is d
...
@@ -10,11 +10,12 @@ purpose of it is to hack it to investigate what your own particular program is d
.. code-block:: python
.. code-block:: python
from theano.gof.link import WrapLinkerMany
from theano.gof.link import WrapLinkerMany
from theano import config
from theano.compile.mode import (Mode, register_mode, predefined_modes, predefined_linkers,
from theano.compile.mode import (Mode, register_mode, predefined_modes, predefined_linkers,
predefined_optimizers
, default_linker, default_optimizer
)
predefined_optimizers)
class StepMode(Mode):
class StepMode(Mode):
def __init__(self, linker=
default_linker, optimizer=default_
optimizer):
def __init__(self, linker=
config.linker, optimizer=config.
optimizer):
def blah(i, node, th):
def blah(i, node, th):
# This function will be run for each node in your compiled program.
# This function will be run for each node in your compiled program.
...
...
doc/tutorial/modes.txt
浏览文件 @
14ceb214
...
@@ -22,9 +22,8 @@ Theano defines the following modes by name:
...
@@ -22,9 +22,8 @@ Theano defines the following modes by name:
but can identify many kinds of problems.
but can identify many kinds of problems.
The default mode is typically ``FAST_RUN``, but it can be controlled via
The default mode is typically ``FAST_RUN``, but it can be controlled via
the configuration variable :attr:`config.mode`, which can in turn be
the configuration variable :attr:`config.mode`,
overridden by setting `theano.compile.mode.default_mode` directly,
which can be overridden by passing the keyword argument to
which can in turn be overridden by passing the keyword argument to
:func:`theano.function <function.function>`.
:func:`theano.function <function.function>`.
================= =============================================================== ===============================================================================
================= =============================================================== ===============================================================================
...
...
theano/compile/function_module.py
浏览文件 @
14ceb214
...
@@ -698,7 +698,7 @@ class FunctionMaker(object):
...
@@ -698,7 +698,7 @@ class FunctionMaker(object):
their output value directly
their output value directly
:param mode: a Mode instance telling FunctionMaker how to optimize and link. None
:param mode: a Mode instance telling FunctionMaker how to optimize and link. None
means to use the `
default_
mode`.
means to use the `
config.
mode`.
:param accept_inplace: True iff it is acceptable to have inplace operations
:param accept_inplace: True iff it is acceptable to have inplace operations
in the graph from the inputs to the outputs
in the graph from the inputs to the outputs
...
@@ -864,7 +864,7 @@ def orig_function(inputs, outputs, mode=None, accept_inplace = False, name=None)
...
@@ -864,7 +864,7 @@ def orig_function(inputs, outputs, mode=None, accept_inplace = False, name=None)
itself or a list of one or more return values)
itself or a list of one or more return values)
:param mode: a descriptive string or a Mode instance. (Default of None means to use
:param mode: a descriptive string or a Mode instance. (Default of None means to use
`
mode.default_
mode` (See below for descriptive string list).
`
config.
mode` (See below for descriptive string list).
:param name: an optional name for this fct. If used, the profile mode will print the time spent in this fct.
:param name: an optional name for this fct. If used, the profile mode will print the time spent in this fct.
...
...
theano/compile/mode.py
浏览文件 @
14ceb214
...
@@ -45,8 +45,6 @@ predefined_linkers = {
...
@@ -45,8 +45,6 @@ predefined_linkers = {
'c&py'
:
gof
.
DualLinker
(
checker
=
check_equal
)
'c&py'
:
gof
.
DualLinker
(
checker
=
check_equal
)
}
}
#Keep default_linker the same as the one for default_mode
default_linker
=
'c|py'
def
register_linker
(
name
,
linker
):
def
register_linker
(
name
,
linker
):
"""Add a `Linker` which can be referred to by `name` in `Mode`."""
"""Add a `Linker` which can be referred to by `name` in `Mode`."""
...
@@ -72,8 +70,6 @@ predefined_optimizers = {
...
@@ -72,8 +70,6 @@ predefined_optimizers = {
'fast_run_stable'
:
OPT_FAST_RUN_STABLE
,
'fast_run_stable'
:
OPT_FAST_RUN_STABLE
,
'fast_compile'
:
OPT_FAST_COMPILE
'fast_compile'
:
OPT_FAST_COMPILE
}
}
#Keep default_optimizer the same as the one for default_mode
default_optimizer
=
'fast_run'
def
register_optimizer
(
name
,
opt
):
def
register_optimizer
(
name
,
opt
):
"""Add a `Optimizer` which can be referred to by `name` in `Mode`."""
"""Add a `Optimizer` which can be referred to by `name` in `Mode`."""
...
@@ -155,7 +151,7 @@ class Mode(object):
...
@@ -155,7 +151,7 @@ class Mode(object):
predefined_modes.
predefined_modes.
"""
"""
def
__init__
(
self
,
linker
=
default_linker
,
optimizer
=
default_
optimizer
):
def
__init__
(
self
,
linker
=
config
.
linker
,
optimizer
=
config
.
optimizer
):
self
.
__setstate__
((
linker
,
optimizer
))
self
.
__setstate__
((
linker
,
optimizer
))
def
__getstate__
(
self
):
def
__getstate__
(
self
):
...
@@ -220,20 +216,19 @@ predefined_modes = {'FAST_COMPILE': FAST_COMPILE,
...
@@ -220,20 +216,19 @@ predefined_modes = {'FAST_COMPILE': FAST_COMPILE,
'FAST_RUN_NOGC'
:
FAST_RUN_NOGC
,
'FAST_RUN_NOGC'
:
FAST_RUN_NOGC
,
'SANITY_CHECK'
:
SANITY_CHECK
}
'SANITY_CHECK'
:
SANITY_CHECK
}
# The default mode used by functions and modules is read from the configuration.
# keep default_mode.optimizer==default_optimizer and default_mode.linker==default_linker!
default_mode
=
config
.
mode
def
get_mode
(
string
):
def
get_mode
(
string
):
if
string
is
None
:
string
=
default_
mode
if
string
is
None
:
string
=
config
.
mode
if
not
isinstance
(
string
,
str
):
return
string
#it is already a mode...
if
not
isinstance
(
string
,
str
):
return
string
#it is already a mode...
if
not
predefined_modes
.
has_key
(
string
):
if
not
predefined_modes
.
has_key
(
string
):
raise
Exception
(
"No predefixed mode exist for string:
%
s"
%
string
)
raise
Exception
(
"No predefixed mode exist for string:
%
s"
%
string
)
return
predefined_modes
[
string
]
return
predefined_modes
[
string
]
def
get_default_mode
():
def
get_default_mode
():
return
get_mode
(
default_mode
)
if
config
.
mode
in
[
'Mode'
,
'ProfileMode'
,
'DebugMode'
]:
return
Mode
(
linker
=
config
.
linker
,
optimizer
=
config
.
optimizer
)
return
get_mode
(
config
.
mode
)
default_mode
=
config
.
mode
def
register_mode
(
name
,
mode
):
def
register_mode
(
name
,
mode
):
"""Add a `Mode` which can be referred to by `name` in `function`."""
"""Add a `Mode` which can be referred to by `name` in `function`."""
...
...
theano/compile/module.py
浏览文件 @
14ceb214
...
@@ -87,7 +87,7 @@ class Component(object):
...
@@ -87,7 +87,7 @@ class Component(object):
be called.
be called.
"""
"""
if
mode
is
None
:
if
mode
is
None
:
mode
=
get_mode
.
default_mode
mode
=
get_mode
.
get_default_mode
()
memo
=
{}
memo
=
{}
self
.
allocate
(
memo
)
self
.
allocate
(
memo
)
rval
=
self
.
build
(
mode
,
memo
)
rval
=
self
.
build
(
mode
,
memo
)
...
@@ -101,7 +101,7 @@ class Component(object):
...
@@ -101,7 +101,7 @@ class Component(object):
arguments and the keyword arguments. If 'mode' is in the
arguments and the keyword arguments. If 'mode' is in the
keyword arguments it will be passed to build().
keyword arguments it will be passed to build().
"""
"""
mode
=
kwargs
.
pop
(
'mode'
,
get_mode
.
default_mode
)
mode
=
kwargs
.
pop
(
'mode'
,
get_mode
.
get_default_mode
()
)
rval
=
self
.
make_no_init
(
mode
)
rval
=
self
.
make_no_init
(
mode
)
if
hasattr
(
rval
,
'initialize'
):
if
hasattr
(
rval
,
'initialize'
):
rval
.
initialize
(
*
args
,
**
kwargs
)
rval
.
initialize
(
*
args
,
**
kwargs
)
...
@@ -1141,7 +1141,7 @@ class Module(ComponentDict):
...
@@ -1141,7 +1141,7 @@ class Module(ComponentDict):
"""
"""
self
.
make_module_instance
(
args
,
kwargs
)
self
.
make_module_instance
(
args
,
kwargs
)
mode
=
kwargs
.
pop
(
'mode'
,
get_mode
.
default_mode
)
mode
=
kwargs
.
pop
(
'mode'
,
get_mode
.
get_default_mode
()
)
rval
=
self
.
make_no_init
(
mode
)
rval
=
self
.
make_no_init
(
mode
)
if
hasattr
(
rval
,
'initialize'
):
if
hasattr
(
rval
,
'initialize'
):
rval
.
initialize
(
*
args
,
**
kwargs
)
rval
.
initialize
(
*
args
,
**
kwargs
)
...
...
theano/compile/profilemode.py
浏览文件 @
14ceb214
...
@@ -2,7 +2,7 @@ import time, atexit, copy
...
@@ -2,7 +2,7 @@ import time, atexit, copy
from
theano.gof.link
import
WrapLinker
from
theano.gof.link
import
WrapLinker
from
theano.gof.cutils
import
run_cthunk
from
theano.gof.cutils
import
run_cthunk
from
theano.compile.mode
import
Mode
,
register_mode
,
predefined_modes
,
predefined_linkers
,
predefined_optimizers
,
default_linker
,
default_optimizer
from
theano.compile.mode
import
Mode
,
register_mode
,
predefined_modes
,
predefined_linkers
,
predefined_optimizers
from
theano.gof.cc
import
OpWiseCLinker
from
theano.gof.cc
import
OpWiseCLinker
from
theano.gof.python25
import
any
from
theano.gof.python25
import
any
from
theano
import
gof
from
theano
import
gof
...
@@ -30,7 +30,7 @@ class Profile_Maker(FunctionMaker):
...
@@ -30,7 +30,7 @@ class Profile_Maker(FunctionMaker):
return
ret
return
ret
class
ProfileMode
(
Mode
):
class
ProfileMode
(
Mode
):
def
__init__
(
self
,
linker
=
default_linker
,
optimizer
=
default_
optimizer
):
def
__init__
(
self
,
linker
=
config
.
linker
,
optimizer
=
config
.
optimizer
):
local_time
=
[
0.0
]
local_time
=
[
0.0
]
apply_time
=
{}
apply_time
=
{}
apply_call
=
{}
apply_call
=
{}
...
...
theano/compile/tests/test_function_module.py
浏览文件 @
14ceb214
import
unittest
import
unittest
from
theano
import
gof
from
theano
import
gof
,
config
from
theano
import
compile
from
theano
import
compile
from
theano.scalar
import
*
from
theano.scalar
import
*
...
@@ -389,10 +389,14 @@ class T_picklefunction(unittest.TestCase):
...
@@ -389,10 +389,14 @@ class T_picklefunction(unittest.TestCase):
sm
=
T
.
dmatrix
(
's'
)
sm
=
T
.
dmatrix
(
's'
)
f
=
function
([
a
,
x
,
s
,
xm
,
sm
],
((
a
.
T
.
T
)
*
(
tensor
.
dot
(
xm
,
(
sm
.
T
.
T
.
T
))
+
x
)
.
T
*
(
x
/
x
)
+
s
))
f
=
function
([
a
,
x
,
s
,
xm
,
sm
],
((
a
.
T
.
T
)
*
(
tensor
.
dot
(
xm
,
(
sm
.
T
.
T
.
T
))
+
x
)
.
T
*
(
x
/
x
)
+
s
))
old_default_mode
=
compile
.
mode
.
default_mode
old_default_mode
=
config
.
mode
old_default_opt
=
config
.
optimizer
old_default_link
=
config
.
linker
try
:
try
:
str_f
=
cPickle
.
dumps
(
f
)
str_f
=
cPickle
.
dumps
(
f
)
compile
.
mode
.
default_mode
=
mode_module
.
Mode
(
linker
=
'py'
,
optimizer
=
None
)
config
.
mode
=
'Mode'
config
.
linker
=
'py'
config
.
optimizer
=
'None'
g
=
cPickle
.
loads
(
str_f
)
g
=
cPickle
.
loads
(
str_f
)
#print g.maker.mode
#print g.maker.mode
#print compile.mode.default_mode
#print compile.mode.default_mode
...
@@ -400,8 +404,10 @@ class T_picklefunction(unittest.TestCase):
...
@@ -400,8 +404,10 @@ class T_picklefunction(unittest.TestCase):
if
e
[
0
]
.
startswith
(
'DebugMode is not pickl'
):
if
e
[
0
]
.
startswith
(
'DebugMode is not pickl'
):
g
=
'ok'
g
=
'ok'
finally
:
finally
:
compile
.
mode
.
default_mode
=
old_default_mode
config
.
mode
=
old_default_mode
config
.
optimizer
=
old_default_opt
config
.
linker
=
old_default_link
if
g
==
'ok'
:
if
g
==
'ok'
:
return
return
...
@@ -545,7 +551,7 @@ if __name__ == '__main__':
...
@@ -545,7 +551,7 @@ if __name__ == '__main__':
unittest
.
TextTestRunner
(
verbosity
=
2
)
.
run
(
suite
)
unittest
.
TextTestRunner
(
verbosity
=
2
)
.
run
(
suite
)
#</boilerplate>
#</boilerplate>
elif
0
:
elif
0
:
theano
.
co
mpile
.
mode
.
default_
mode
=
'FAST_COMPILE'
theano
.
co
nfig
.
mode
=
'FAST_COMPILE'
t
=
T_picklefunction
()
t
=
T_picklefunction
()
def
fu
(
b
):
def
fu
(
b
):
assert
b
assert
b
...
...
theano/compile/tests/test_misc.py
浏览文件 @
14ceb214
...
@@ -40,7 +40,6 @@ class NNet(object):
...
@@ -40,7 +40,6 @@ class NNet(object):
class
TestNnet
(
unittest
.
TestCase
):
class
TestNnet
(
unittest
.
TestCase
):
def
test_nnet
(
self
):
def
test_nnet
(
self
):
#theano.compile.default_mode = 'FAST_RUN'
rng
=
numpy
.
random
.
RandomState
(
1827
)
rng
=
numpy
.
random
.
RandomState
(
1827
)
data
=
rng
.
rand
(
10
,
4
)
data
=
rng
.
rand
(
10
,
4
)
nnet
=
NNet
(
n_input
=
3
,
n_hidden
=
10
)
nnet
=
NNet
(
n_input
=
3
,
n_hidden
=
10
)
...
...
theano/compile/tests/test_module.py
浏览文件 @
14ceb214
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
__docformat__
=
"restructuredtext en"
__docformat__
=
"restructuredtext en"
import
cPickle
,
numpy
,
unittest
import
cPickle
,
numpy
,
unittest
from
theano
.compile.mode
import
default_mode
from
theano
import
config
from
theano.compile.module
import
*
from
theano.compile.module
import
*
from
theano.compile.function_module
import
AliasedMemoryError
from
theano.compile.function_module
import
AliasedMemoryError
import
theano.tensor
as
T
import
theano.tensor
as
T
...
@@ -435,7 +435,7 @@ class T_module(unittest.TestCase):
...
@@ -435,7 +435,7 @@ class T_module(unittest.TestCase):
"""Test that we can manipulate the mutable, strict, etc. flags (see SymbolicInput) of
"""Test that we can manipulate the mutable, strict, etc. flags (see SymbolicInput) of
Method inputs"""
Method inputs"""
if
default_
mode
==
'FAST_COMPILE'
:
if
config
.
mode
==
'FAST_COMPILE'
:
return
return
M
=
Module
()
M
=
Module
()
...
@@ -696,8 +696,8 @@ def test_method_implicit_ticket_384():
...
@@ -696,8 +696,8 @@ def test_method_implicit_ticket_384():
raise
raise
def
get_mode
():
def
get_mode
():
if
default_
mode
!=
'DEBUG_MODE'
:
if
config
.
mode
!=
'DEBUG_MODE'
:
mode
=
default_
mode
mode
=
config
.
mode
else
:
mode
=
'FAST_RUN'
else
:
mode
=
'FAST_RUN'
return
mode
return
mode
...
...
theano/compile/tests/test_pfunc.py
浏览文件 @
14ceb214
...
@@ -443,6 +443,6 @@ class Test_pfunc(unittest.TestCase):
...
@@ -443,6 +443,6 @@ class Test_pfunc(unittest.TestCase):
self
.
failUnlessRaises
(
TypeError
,
pfunc
,
[],
x
)
self
.
failUnlessRaises
(
TypeError
,
pfunc
,
[],
x
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
theano
.
co
mpile
.
mode
.
default_
mode
=
'FAST_COMPILE'
theano
.
co
nfig
.
mode
=
'FAST_COMPILE'
Test_pfunc
()
.
test_default_scalar_container
()
Test_pfunc
()
.
test_default_scalar_container
()
theano/configdefaults.py
浏览文件 @
14ceb214
...
@@ -13,9 +13,20 @@ AddConfigVar('device',
...
@@ -13,9 +13,20 @@ AddConfigVar('device',
EnumStr
(
'cpu'
,
*
[
'gpu
%
i'
%
i
for
i
in
range
(
4
)])
EnumStr
(
'cpu'
,
*
[
'gpu
%
i'
%
i
for
i
in
range
(
4
)])
)
)
# keep the default mode.optimizer==config.optimizer and mode.linker==config.linker!
AddConfigVar
(
'mode'
,
AddConfigVar
(
'mode'
,
"Default compilation mode"
,
"Default compilation mode"
,
EnumStr
(
'FAST_RUN'
,
'FAST_COMPILE'
,
'PROFILE_MODE'
,
'DEBUG_MODE'
))
EnumStr
(
'FAST_RUN'
,
'FAST_COMPILE'
,
'PROFILE_MODE'
,
'DEBUG_MODE'
,
'Mode'
,
'ProfileMode'
,
'DebugMode'
))
#Keep the default linker the same as the one for the mode
AddConfigVar
(
'linker'
,
"Default linker. If not None, will use this linker with the Mode object(not ProfileMode or DebugMode)"
,
EnumStr
(
'c|py'
,
'py'
,
'c'
,
'c|py_nogc'
,
'c&py'
))
#Keep the default optimizer the same as the one for the mode
AddConfigVar
(
'optimizer'
,
"Default optimizer. If not None, will use this linker with the Mode object(not ProfileMode or DebugMode)"
,
EnumStr
(
'fast_run'
,
'merge'
,
'fast_compile'
,
'None'
))
AddConfigVar
(
'home'
,
AddConfigVar
(
'home'
,
"User home directory"
,
"User home directory"
,
...
...
theano/tensor/nnet/tests/test_conv.py
浏览文件 @
14ceb214
...
@@ -53,7 +53,8 @@ class TestConv2D(unittest.TestCase):
...
@@ -53,7 +53,8 @@ class TestConv2D(unittest.TestCase):
theano_output
=
theano_conv
(
image_data
,
filter_data
)
theano_output
=
theano_conv
(
image_data
,
filter_data
)
############# REFERENCE IMPLEMENTATION ############
############# REFERENCE IMPLEMENTATION ############
s
=
1.
if
border_mode
is
'full'
else
-
1.
s
=
1.
if
border_mode
is
not
'full'
:
s
=
-
1.
out_shape2d
=
numpy
.
array
(
N_image_shape
[
-
2
:])
+
\
out_shape2d
=
numpy
.
array
(
N_image_shape
[
-
2
:])
+
\
s
*
numpy
.
array
(
N_filter_shape
[
-
2
:])
-
s
s
*
numpy
.
array
(
N_filter_shape
[
-
2
:])
-
s
out_shape2d
=
numpy
.
ceil
(
out_shape2d
/
numpy
.
array
(
subsample
))
out_shape2d
=
numpy
.
ceil
(
out_shape2d
/
numpy
.
array
(
subsample
))
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
14ceb214
...
@@ -14,14 +14,14 @@ from theano.gof.python25 import any, all
...
@@ -14,14 +14,14 @@ from theano.gof.python25 import any, all
from
theano
import
gof
from
theano
import
gof
from
theano.tensor.elemwise
import
DimShuffle
from
theano.tensor.elemwise
import
DimShuffle
from
theano.compile.mode
import
default_mode
from
theano.compile.mode
import
get_
default_mode
from
theano
import
function
from
theano
import
function
from
theano.tests
import
unittest_tools
as
utt
from
theano.tests
import
unittest_tools
as
utt
### seed random number generator so that unittests are deterministic ###
### seed random number generator so that unittests are deterministic ###
utt
.
seed_rng
()
utt
.
seed_rng
()
def
inplace_func
(
inputs
,
outputs
,
mode
=
default_mode
):
def
inplace_func
(
inputs
,
outputs
,
mode
=
get_default_mode
()
):
return
function
(
inputs
,
outputs
,
mode
=
mode
,
accept_inplace
=
True
)
return
function
(
inputs
,
outputs
,
mode
=
mode
,
accept_inplace
=
True
)
...
...
theano/tensor/tests/test_naacl09.py
浏览文件 @
14ceb214
...
@@ -4,7 +4,7 @@ import theano
...
@@ -4,7 +4,7 @@ import theano
from
theano
import
tensor
as
T
from
theano
import
tensor
as
T
from
theano.tensor
import
nnet
as
NN
from
theano.tensor
import
nnet
as
NN
from
theano.compile
import
module
from
theano.compile
import
module
from
theano.compile.mode
import
default_mode
from
theano.compile.mode
import
get_
default_mode
from
theano
import
tensor
as
T
,
sparse
as
S
from
theano
import
tensor
as
T
,
sparse
as
S
import
numpy
as
N
import
numpy
as
N
import
sys
import
sys
...
@@ -524,7 +524,7 @@ def test_naacl_model(iters_per_unsup=3, iters_per_sup=3,
...
@@ -524,7 +524,7 @@ def test_naacl_model(iters_per_unsup=3, iters_per_sup=3,
if
optimizer
:
if
optimizer
:
mode
=
theano
.
Mode
(
linker
=
'c|py'
,
optimizer
=
optimizer
)
mode
=
theano
.
Mode
(
linker
=
'c|py'
,
optimizer
=
optimizer
)
else
:
mode
=
default_mode
else
:
mode
=
get_default_mode
()
if
realistic
:
if
realistic
:
m
=
create_realistic
(
compile_mode
=
mode
)
m
=
create_realistic
(
compile_mode
=
mode
)
else
:
else
:
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
14ceb214
...
@@ -202,7 +202,7 @@ class test_canonize(unittest.TestCase):
...
@@ -202,7 +202,7 @@ class test_canonize(unittest.TestCase):
#We must be sure that the Canonizer is working, but that we don't have other
#We must be sure that the Canonizer is working, but that we don't have other
# optimisation that could hide bug in the Canonizer as local_elemwise_fusion
# optimisation that could hide bug in the Canonizer as local_elemwise_fusion
mode
=
compile
.
mode
.
predefined_modes
[
compile
.
mode
.
default_mode
]
mode
=
compile
.
mode
.
get_default_mode
()
old_optimizer
=
mode
.
_optimizer
old_optimizer
=
mode
.
_optimizer
try
:
try
:
mode
.
_optimizer
=
gof
.
Query
([
"canonicalize"
])
mode
.
_optimizer
=
gof
.
Query
([
"canonicalize"
])
...
@@ -282,7 +282,7 @@ class test_canonize(unittest.TestCase):
...
@@ -282,7 +282,7 @@ class test_canonize(unittest.TestCase):
#We must be sure that the Canonizer is working, but that we don't have other
#We must be sure that the Canonizer is working, but that we don't have other
# optimisation that could hide bug in the Canonizer as local_elemwise_fusion
# optimisation that could hide bug in the Canonizer as local_elemwise_fusion
mode
=
compile
.
mode
.
predefined_modes
[
compile
.
mode
.
default_mode
]
mode
=
compile
.
mode
.
get_default_mode
()
mode
.
_optimizer
=
gof
.
Query
([
"canonicalize"
])
mode
.
_optimizer
=
gof
.
Query
([
"canonicalize"
])
mode
.
_optimizer
=
mode
.
_optimizer
.
excluding
(
'local_elemwise_fusion'
)
mode
.
_optimizer
=
mode
.
_optimizer
.
excluding
(
'local_elemwise_fusion'
)
for
id
,
[
g
,
sym_inputs
,
val_inputs
,
nb_elemwise
,
out_dtype
]
in
enumerate
(
cases
):
for
id
,
[
g
,
sym_inputs
,
val_inputs
,
nb_elemwise
,
out_dtype
]
in
enumerate
(
cases
):
...
@@ -327,7 +327,7 @@ class test_canonize(unittest.TestCase):
...
@@ -327,7 +327,7 @@ class test_canonize(unittest.TestCase):
#We must be sure that the Canonizer is working, but that we don't have other
#We must be sure that the Canonizer is working, but that we don't have other
# optimisation that could hide bug in the Canonizer as local_elemwise_fusion
# optimisation that could hide bug in the Canonizer as local_elemwise_fusion
mode
=
compile
.
mode
.
predefined_modes
[
compile
.
mode
.
default_mode
]
mode
=
compile
.
mode
.
get_default_mode
()
old_optimizer
=
mode
.
_optimizer
old_optimizer
=
mode
.
_optimizer
try
:
try
:
mode
.
_optimizer
=
gof
.
Query
([
"canonicalize"
])
mode
.
_optimizer
=
gof
.
Query
([
"canonicalize"
])
...
@@ -474,7 +474,7 @@ class test_canonize(unittest.TestCase):
...
@@ -474,7 +474,7 @@ class test_canonize(unittest.TestCase):
fvv
=
theano
.
_asarray
(
numpy
.
random
.
rand
(
shp
[
0
]),
dtype
=
'float32'
)
.
reshape
(
1
,
shp
[
0
])
fvv
=
theano
.
_asarray
(
numpy
.
random
.
rand
(
shp
[
0
]),
dtype
=
'float32'
)
.
reshape
(
1
,
shp
[
0
])
#We must be sure that the Canonizer is working, but that we don't have other
#We must be sure that the Canonizer is working, but that we don't have other
# optimisation that could hide bug in the Canonizer as local_elemwise_fusion
# optimisation that could hide bug in the Canonizer as local_elemwise_fusion
mode
=
compile
.
mode
.
predefined_modes
[
compile
.
mode
.
default_mode
]
mode
=
compile
.
mode
.
get_default_mode
()
old_optimizer
=
mode
.
_optimizer
old_optimizer
=
mode
.
_optimizer
try
:
try
:
mode
.
_optimizer
=
gof
.
Query
([
"canonicalize"
])
mode
.
_optimizer
=
gof
.
Query
([
"canonicalize"
])
...
@@ -907,7 +907,7 @@ class test_fusion(unittest.TestCase):
...
@@ -907,7 +907,7 @@ class test_fusion(unittest.TestCase):
#g.owner.inputs[0] is out... make owner a weakref?
#g.owner.inputs[0] is out... make owner a weakref?
def
test_log1p
():
def
test_log1p
():
m
=
theano
.
co
mpile
.
default_
mode
m
=
theano
.
co
nfig
.
mode
if
m
==
'FAST_COMPILE'
:
if
m
==
'FAST_COMPILE'
:
m
=
'FAST_RUN'
m
=
'FAST_RUN'
...
@@ -942,7 +942,7 @@ def test_log1p():
...
@@ -942,7 +942,7 @@ def test_log1p():
f
=
function
([
z
],
T
.
log
(
1
+
(
z
)),
mode
=
m
)
f
=
function
([
z
],
T
.
log
(
1
+
(
z
)),
mode
=
m
)
assert
[
node
.
op
for
node
in
f
.
maker
.
env
.
toposort
()]
==
[
T
.
log1p
]
assert
[
node
.
op
for
node
in
f
.
maker
.
env
.
toposort
()]
==
[
T
.
log1p
]
class
test_local_subtensor_unary
():
class
test_local_subtensor_unary
(
unittest
.
TestCase
):
def
test0
(
self
):
def
test0
(
self
):
# basic test that the Op works
# basic test that the Op works
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论