Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
de05e842
提交
de05e842
authored
2月 20, 2013
作者:
lamblin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1224 from abalkin/no-relative-imports
Issue #783: python3 compatible - remove relative imports.
上级
cdaaf137
57b23ab3
隐藏空白字符变更
内嵌
并排
正在显示
45 个修改的文件
包含
214 行增加
和
220 行删除
+214
-220
__init__.py
theano/__init__.py
+59
-54
__init__.py
theano/compile/__init__.py
+10
-17
function.py
theano/compile/function.py
+3
-3
function_module.py
theano/compile/function_module.py
+5
-5
module.py
theano/compile/module.py
+6
-6
pfunc.py
theano/compile/pfunc.py
+2
-2
sharedvalue.py
theano/compile/sharedvalue.py
+0
-1
__init__.py
theano/gof/__init__.py
+12
-14
cc.py
theano/gof/cc.py
+5
-5
cmodule.py
theano/gof/cmodule.py
+2
-2
cutils.py
theano/gof/cutils.py
+1
-1
fg.py
theano/gof/fg.py
+6
-5
link.py
theano/gof/link.py
+3
-4
op.py
theano/gof/op.py
+5
-6
opt.py
theano/gof/opt.py
+6
-7
optdb.py
theano/gof/optdb.py
+2
-2
sched.py
theano/gof/sched.py
+1
-1
toolbox.py
theano/gof/toolbox.py
+1
-1
type.py
theano/gof/type.py
+3
-3
unify.py
theano/gof/unify.py
+2
-2
vm.py
theano/gof/vm.py
+2
-3
ifelse.py
theano/ifelse.py
+5
-5
printing.py
theano/printing.py
+2
-2
raise_op.py
theano/raise_op.py
+1
-1
__init__.py
theano/scan_module/__init__.py
+4
-4
scan.py
theano/scan_module/scan.py
+3
-3
scan_op.py
theano/scan_module/scan_op.py
+2
-2
scan_opt.py
theano/scan_module/scan_opt.py
+3
-3
scan_views.py
theano/scan_module/scan_views.py
+3
-3
opt.py
theano/sparse/opt.py
+2
-3
sharedvar.py
theano/sparse/sharedvar.py
+8
-6
__init__.py
theano/tensor/__init__.py
+22
-21
basic.py
theano/tensor/basic.py
+2
-2
blas_c.py
theano/tensor/blas_c.py
+4
-4
elemwise.py
theano/tensor/elemwise.py
+1
-1
extra_ops.py
theano/tensor/extra_ops.py
+2
-2
io.py
theano/tensor/io.py
+1
-1
opt.py
theano/tensor/opt.py
+3
-3
opt_uncanonicalize.py
theano/tensor/opt_uncanonicalize.py
+3
-3
raw_random.py
theano/tensor/raw_random.py
+2
-2
shared_randomstreams.py
theano/tensor/shared_randomstreams.py
+1
-1
sharedvar.py
theano/tensor/sharedvar.py
+1
-1
sort.py
theano/tensor/sort.py
+1
-1
test_naacl09.py
theano/tensor/tests/test_naacl09.py
+1
-1
xlogx.py
theano/tensor/xlogx.py
+1
-1
没有找到文件。
theano/__init__.py
浏览文件 @
de05e842
...
...
@@ -31,36 +31,28 @@ import logging
theano_logger
=
logging
.
getLogger
(
"theano"
)
logging_default_handler
=
logging
.
StreamHandler
()
logging_default_formatter
=
logging
.
Formatter
(
fmt
=
'
%(levelname)
s (
%(name)
s):
%(message)
s'
)
fmt
=
'
%(levelname)
s (
%(name)
s):
%(message)
s'
)
logging_default_handler
.
setFormatter
(
logging_default_formatter
)
theano_logger
.
addHandler
(
logging_default_handler
)
theano_logger
.
setLevel
(
logging
.
WARNING
)
import
configparser
import
configdefaults
config
=
configparser
.
TheanoConfigParser
()
from
theano.configdefaults
import
config
# Version information.
import
theano.version
__version__
=
theano
.
version
.
version
import
gof
from
gof
import
\
CLinker
,
OpWiseCLinker
,
DualLinker
,
Linker
,
LocalLinker
,
PerformLinker
,
\
Container
,
\
InconsistencyError
,
FunctionGraph
,
\
Apply
,
Variable
,
Constant
,
\
Op
,
OpenMPOp
,
\
opt
,
\
toolbox
,
\
Type
,
Generic
,
generic
,
\
object2
,
utils
import
compile
from
compile
import
\
from
theano.version
import
version
as
__version__
from
theano.gof
import
\
CLinker
,
OpWiseCLinker
,
DualLinker
,
Linker
,
LocalLinker
,
PerformLinker
,
\
Container
,
\
InconsistencyError
,
FunctionGraph
,
\
Apply
,
Variable
,
Constant
,
\
Op
,
OpenMPOp
,
\
opt
,
\
toolbox
,
\
Type
,
Generic
,
generic
,
\
object2
,
utils
from
theano.compile
import
\
SymbolicInput
,
In
,
\
SymbolicOutput
,
Out
,
\
Mode
,
\
...
...
@@ -71,43 +63,37 @@ from compile import \
ProfileMode
,
\
Param
,
shared
from
misc.safe_asarray
import
_asarray
import
theano.tests
if
hasattr
(
theano
.
tests
,
"TheanoNoseTester"
):
test
=
theano
.
tests
.
TheanoNoseTester
()
.
test
else
:
def
test
():
raise
ImportError
(
"The nose module is not installed."
" It is needed for Theano tests."
)
from
theano.misc.safe_asarray
import
_asarray
FancyModule
=
Module
from
printing
import
\
pprint
,
pp
import
scan_module
from
scan_module
import
scan
,
map
,
reduce
,
foldl
,
foldr
,
clone
from
theano.printing
import
pprint
,
pp
from
theano.scan_module
import
scan
,
map
,
reduce
,
foldl
,
foldr
,
clone
from
updates
import
Updates
,
OrderedUpdates
from
theano.
updates
import
Updates
,
OrderedUpdates
import
tensor
import
scalar
# scan_module import above initializes tensor and scalar making these imports redundant
#import tensor
#import scalar
#we don't import by default as we don't want to force having scipy installed.
#import sparse
import
gradient
from
gradient
import
Rop
,
Lop
,
grad
from
theano.
gradient
import
Rop
,
Lop
,
grad
if
config
.
device
.
startswith
(
'gpu'
)
or
config
.
init_gpu_device
.
startswith
(
'gpu'
):
import
theano.sandbox.cuda
# We can't test the driver during import of theano.sandbox.cuda as
# this cause circular import dependency. So we also test it manually
# after the import
# We can't test the driver during import of theano.sandbox.cuda as
# this cause circular import dependency. So we also test it manually
# after the import
if
theano
.
sandbox
.
cuda
.
cuda_available
:
import
theano.sandbox.cuda.tests.test_driver
theano
.
sandbox
.
cuda
.
tests
.
test_driver
.
test_nvidia_driver1
()
# Use config.numpy to call numpy.seterr
import
numpy
if
config
.
numpy
.
seterr_all
==
'None'
:
_all
=
None
else
:
...
...
@@ -129,11 +115,11 @@ if config.numpy.seterr_invalid == 'None':
else
:
_invalid
=
config
.
numpy
.
seterr_invalid
numpy
.
seterr
(
all
=
_all
,
divide
=
_divide
,
over
=
_over
,
under
=
_under
,
invalid
=
_invalid
)
all
=
_all
,
divide
=
_divide
,
over
=
_over
,
under
=
_under
,
invalid
=
_invalid
)
del
_all
,
_divide
,
_over
,
_under
,
_invalid
## import scalar_opt
...
...
@@ -174,10 +160,28 @@ def get_scalar_constant_value(v):
If `v` is not some view of constant data, then raise a
tensor.basic.NotScalarConstantError.
"""
if
hasattr
(
theano
,
'sparse'
)
and
isinstance
(
v
.
type
,
theano
.
sparse
.
SparseType
):
if
v
.
owner
is
not
None
and
isinstance
(
v
.
owner
.
op
,
theano
.
sparse
.
CSM
):
# Is it necessary to test for presence of theano.sparse at runtime?
if
'sparse'
in
globals
()
and
isinstance
(
v
.
type
,
sparse
.
SparseType
):
if
v
.
owner
is
not
None
and
isinstance
(
v
.
owner
.
op
,
sparse
.
CSM
):
data
=
v
.
owner
.
inputs
[
0
]
return
tensor
.
get_scalar_constant_value
(
data
)
return
tensor
.
get_scalar_constant_value
(
v
)
import
theano.tests
if
hasattr
(
theano
.
tests
,
"TheanoNoseTester"
):
test
=
theano
.
tests
.
TheanoNoseTester
()
.
test
else
:
def
test
():
raise
ImportError
(
"The nose module is not installed."
" It is needed for Theano tests."
)
# This cannot be done in tensor/__init__.py due to a circular dependency -- randomstreams
# depends on raw_random which depends on tensor. As a work-around, we import RandomStreams
# here and inject an instance in tensor.
from
theano
import
tensor
from
theano.tensor.randomstreams
import
RandomStreams
# Imitate the numpy.random symbol with a tensor.random one
tensor
.
random
=
RandomStreams
(
seed
=
0xBAD5EED
,
no_warn
=
True
)
del
RandomStreams
__import__
(
'theano.tensor.shared_randomstreams'
)
\ No newline at end of file
theano/compile/__init__.py
浏览文件 @
de05e842
import
ops
from
ops
import
(
from
theano.compile.ops
import
(
DeepCopyOp
,
deep_copy_op
,
register_deep_copy_op_c_code
,
ViewOp
,
view_op
,
register_view_op_c_code
)
import
function_module
from
function_module
import
*
from
theano.compile.function_module
import
*
import
mode
from
mode
import
*
from
theano.compile.mode
import
*
import
io
from
io
import
*
from
theano.compile.io
import
*
import
builders
from
builders
import
*
from
theano.compile.builders
import
*
import
module
from
module
import
*
from
theano.compile.module
import
*
import
debugmode
# register DEBUG_MODE
from
debugmode
import
DebugMode
from
theano.compile.debugmode
import
DebugMode
from
monitormode
import
MonitorMode
from
theano.compile.
monitormode
import
MonitorMode
from
profilemode
import
ProfileMode
from
theano.compile.
profilemode
import
ProfileMode
from
theano.compile.sharedvalue
import
shared
,
shared_constructor
,
SharedVariable
from
theano.compile.pfunc
import
pfunc
,
Param
,
rebuild_collect_shared
from
function
import
function
from
theano.compile.
function
import
function
theano/compile/function.py
浏览文件 @
de05e842
...
...
@@ -5,9 +5,9 @@ __docformat__ = "restructuredtext en"
import
logging
_logger
=
logging
.
getLogger
(
'theano.compile.function'
)
from
io
import
In
from
function_module
import
orig_function
from
pfunc
import
pfunc
from
theano.compile.
io
import
In
from
theano.compile.
function_module
import
orig_function
from
theano.compile.
pfunc
import
pfunc
from
numpy
import
any
# to work in python 2.4
import
warnings
from
theano
import
gof
...
...
theano/compile/function_module.py
浏览文件 @
de05e842
...
...
@@ -15,8 +15,8 @@ import numpy
import
theano
from
theano
import
gof
from
theano.gof.python25
import
partial
import
mode
as
mode_modul
e
from
io
import
In
,
SymbolicInput
,
SymbolicInputKit
,
SymbolicOutput
import
theano.compile.mod
e
from
theano.compile.
io
import
In
,
SymbolicInput
,
SymbolicInputKit
,
SymbolicOutput
from
theano.compile.ops
import
deep_copy_op
,
view_op
import
logging
...
...
@@ -945,7 +945,7 @@ class FunctionMaker(object):
- 'ignore': do not do anything
- None: Use the value in the Theano flags on_unused_input
"""
mode
=
mode_modul
e
.
get_mode
(
mode
)
mode
=
theano
.
compile
.
mod
e
.
get_mode
(
mode
)
# figure out which profile object to use (if any)
# to help with forward-porting ProfileMode,
...
...
@@ -1025,7 +1025,7 @@ class FunctionMaker(object):
# initialize the linker
if
not
hasattr
(
linker
,
'accept'
):
raise
ValueError
(
"'linker' parameter of FunctionFactory should be a Linker with an accept method "
\
"or one of
%
s"
%
mode_modul
e
.
predefined_linkers
.
keys
())
"or one of
%
s"
%
theano
.
compile
.
mod
e
.
predefined_linkers
.
keys
())
#the 'no_borrow' outputs are the ones for which that we can't return the internal storage pointer.
assert
len
(
fgraph
.
outputs
)
==
len
(
outputs
+
additional_outputs
)
...
...
@@ -1274,7 +1274,7 @@ def orig_function(inputs, outputs, mode=None, accept_inplace=False,
# instance if necessary:
t1
=
time
.
time
()
mode
=
mode_modul
e
.
get_mode
(
mode
)
mode
=
theano
.
compile
.
mod
e
.
get_mode
(
mode
)
inputs
=
map
(
convert_function_input
,
inputs
)
if
outputs
is
not
None
:
...
...
theano/compile/module.py
浏览文件 @
de05e842
...
...
@@ -15,8 +15,8 @@ import warnings
from
itertools
import
chain
import
function_module
as
F
import
mode
as
get_
mode
import
theano.compile.function_module
import
theano.compile.
mode
#This module is imported by other parts of theano, and worse still, other
...
...
@@ -106,7 +106,7 @@ class Component(object):
be called.
"""
if
mode
is
None
:
mode
=
get_
mode
.
get_default_mode
()
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
memo
=
{}
self
.
allocate
(
memo
)
rval
=
self
.
build
(
mode
,
memo
)
...
...
@@ -120,7 +120,7 @@ class Component(object):
arguments and the keyword arguments. If 'mode' is in the
keyword arguments it will be passed to build().
"""
mode
=
kwargs
.
pop
(
'mode'
,
get_
mode
.
get_default_mode
())
mode
=
kwargs
.
pop
(
'mode'
,
theano
.
compile
.
mode
.
get_default_mode
())
rval
=
self
.
make_no_init
(
mode
)
if
hasattr
(
rval
,
'initialize'
):
rval
.
initialize
(
*
args
,
**
kwargs
)
...
...
@@ -503,7 +503,7 @@ class Method(Component):
effective_mode
=
self
.
mode
# We ignore unused inputs, since all the inputs are passed
rval
=
F
.
orig_function
(
inputs
,
outputs
,
effective_mode
,
rval
=
theano
.
compile
.
function_module
.
orig_function
(
inputs
,
outputs
,
effective_mode
,
on_unused_input
=
'ignore'
)
memo
[
self
]
=
rval
return
rval
...
...
@@ -1192,7 +1192,7 @@ class Module(ComponentDict):
"""
self
.
make_module_instance
(
args
,
kwargs
)
mode
=
kwargs
.
pop
(
'mode'
,
get_
mode
.
get_default_mode
())
mode
=
kwargs
.
pop
(
'mode'
,
theano
.
compile
.
mode
.
get_default_mode
())
rval
=
self
.
make_no_init
(
mode
)
if
hasattr
(
rval
,
'initialize'
):
rval
.
initialize
(
*
args
,
**
kwargs
)
...
...
theano/compile/pfunc.py
浏览文件 @
de05e842
...
...
@@ -3,12 +3,11 @@
__docformat__
=
'restructuredtext en'
from
profiling
import
ProfileStats
from
theano
import
config
from
theano.compile
import
orig_function
,
In
,
Out
from
theano.compile
import
UnusedInputError
from
theano.compile.sharedvalue
import
SharedVariable
,
shared
from
theano.compile.profiling
import
ProfileStats
from
theano.gof
import
Variable
,
Constant
from
theano.gof.python25
import
any
...
...
@@ -293,6 +292,7 @@ class Param(object):
`mutable` flag.
False: do not permit any output to be aliased to the input
False: do not permit any output to be aliased to the input
:param strict: False -> function arguments may be copied or cast to match the
type required by the parameter `variable`.
True -> function arguments must exactly match the type
...
...
theano/compile/sharedvalue.py
浏览文件 @
de05e842
...
...
@@ -4,7 +4,6 @@ __docformat__ = 'restructuredtext en'
# Standard imports
import
copy
import
logging
import
sys
# Third-party imports
import
numpy
...
...
theano/gof/__init__.py
浏览文件 @
de05e842
...
...
@@ -35,29 +35,27 @@ For more details and discussion, see the theano-dev
e-mail thread "What is gof?"
"""
import
sys
from
cc
import
\
from
theano.gof.cc
import
\
CLinker
,
OpWiseCLinker
,
DualLinker
import
compiledir
# adds config vars
import
theano.gof.
compiledir
# adds config vars
from
fg
import
\
from
theano.gof.
fg
import
\
InconsistencyError
,
MissingInputError
,
FunctionGraph
from
destroyhandler
import
\
from
theano.gof.
destroyhandler
import
\
DestroyHandler
from
graph
import
\
from
theano.gof.
graph
import
\
Apply
,
Variable
,
Constant
,
view_roots
from
link
import
\
from
theano.gof.
link
import
\
Container
,
Linker
,
LocalLinker
,
PerformLinker
,
WrapLinker
,
WrapLinkerMany
from
op
import
\
from
theano.gof.
op
import
\
Op
,
OpenMPOp
,
PureOp
,
ops_with_inner_function
from
opt
import
(
Optimizer
,
optimizer
,
SeqOptimizer
,
from
theano.gof.
opt
import
(
Optimizer
,
optimizer
,
SeqOptimizer
,
MergeOptimizer
,
MergeOptMerge
,
LocalOptimizer
,
local_optimizer
,
LocalOptGroup
,
OpSub
,
OpRemove
,
PatternSub
,
...
...
@@ -65,18 +63,18 @@ from opt import (Optimizer, optimizer, SeqOptimizer,
InplaceOptimizer
,
PureThenInplaceOptimizer
,
OpKeyOptimizer
)
from
optdb
import
\
from
theano.gof.
optdb
import
\
DB
,
Query
,
\
EquilibriumDB
,
SequenceDB
,
ProxyDB
from
toolbox
import
\
from
t
heano.gof.t
oolbox
import
\
Feature
,
\
Bookkeeper
,
History
,
Validator
,
ReplaceValidate
,
NodeFinder
,
\
PrintListener
,
ReplacementDidntRemovedError
from
type
import
\
from
t
heano.gof.t
ype
import
\
Type
,
Generic
,
generic
from
utils
import
\
from
theano.gof.
utils
import
\
object2
,
MethodNotDefined
theano/gof/cc.py
浏览文件 @
de05e842
...
...
@@ -44,13 +44,13 @@ AddConfigVar('gcc.cxxflags',
StrParam
(
""
))
# gof imports
import
graph
import
link
import
utils
from
theano.gof
import
graph
from
theano.gof
import
link
from
theano.gof
import
utils
from
compilelock
import
get_lock
,
release_lock
from
theano.gof.
compilelock
import
get_lock
,
release_lock
import
cmodule
from
theano.gof
import
cmodule
import
logging
...
...
theano/gof/cmodule.py
浏览文件 @
de05e842
...
...
@@ -25,8 +25,8 @@ from theano.gof.cc import hash_from_code
from
theano.misc.windows
import
call_subprocess_Popen
# we will abuse the lockfile mechanism when reading and writing the registry
import
compilelock
from
compiledir
import
gcc_version_str
from
theano.gof
import
compilelock
from
theano.gof.
compiledir
import
gcc_version_str
from
theano.configparser
import
AddConfigVar
,
BoolParam
...
...
theano/gof/cutils.py
浏览文件 @
de05e842
import
os
import
sys
from
compilelock
import
get_lock
,
release_lock
from
theano.gof.
compilelock
import
get_lock
,
release_lock
from
theano
import
config
# TODO These two lines may be removed in the future, when we are 100% sure
...
...
theano/gof/fg.py
浏览文件 @
de05e842
...
...
@@ -5,14 +5,15 @@ Contains the FunctionGraph class and exception
types that it can raise
"""
import
sys
import
graph
import
utils
import
toolbox
from
python25
import
all
from
theano.gof
import
graph
from
theano.gof
import
utils
from
theano.gof
import
toolbox
from
theano.gof.
python25
import
all
from
theano
import
config
import
warnings
NullType
=
None
from
python25
import
OrderedDict
from
theano.gof.python25
import
OrderedDict
from
theano.misc.ordered_set
import
OrderedSet
class
InconsistencyError
(
Exception
):
...
...
theano/gof/link.py
浏览文件 @
de05e842
"""WRITEME"""
import
utils
import
graph
from
type
import
Type
from
theano.gof
import
utils
from
theano.gof
import
graph
from
t
heano.gof.t
ype
import
Type
import
sys
,
traceback
from
copy
import
copy
from
theano.gof.python25
import
all
__excepthook
=
sys
.
excepthook
...
...
theano/gof/op.py
浏览文件 @
de05e842
...
...
@@ -11,7 +11,6 @@ __contact__ = "theano-dev <theano-dev@googlegroups.com>"
__docformat__
=
"restructuredtext en"
import
copy
import
logging
import
os
import
subprocess
...
...
@@ -22,10 +21,10 @@ import theano
from
theano
import
config
from
theano.misc.windows
import
call_subprocess_Popen
import
cc
import
graph
import
utils
from
fg
import
FunctionGraph
import
theano.gof.
cc
from
theano.gof
import
graph
from
theano.gof
import
utils
from
theano.gof.
fg
import
FunctionGraph
class
CLinkerObject
(
object
):
...
...
@@ -572,7 +571,7 @@ class Op(utils.object2, PureOp, CLinkerOp):
e_no_recycling
=
[
new_o
for
(
new_o
,
old_o
)
in
zip
(
e
.
outputs
,
node
.
outputs
)
if
old_o
in
no_recycling
]
cl
=
cc
.
CLinker
()
.
accept
(
e
,
cl
=
theano
.
gof
.
cc
.
CLinker
()
.
accept
(
e
,
no_recycling
=
e_no_recycling
)
logger
.
debug
(
'Trying CLinker.make_thunk'
)
...
...
theano/gof/opt.py
浏览文件 @
de05e842
...
...
@@ -10,16 +10,15 @@ import time
import
numpy
import
graph
from
fg
import
InconsistencyError
import
op
import
utils
import
unify
import
toolbox
from
theano.gof
import
graph
from
theano.gof.
fg
import
InconsistencyError
from
theano.gof
import
op
from
theano.gof
import
utils
from
theano.gof
import
unify
from
theano.gof
import
toolbox
import
theano
from
theano
import
config
from
theano.gof.python25
import
any
,
all
,
deque
from
theano.configparser
import
AddConfigVar
,
BoolParam
#if sys.version_info[:2] >= (2,5):
# from collections import defaultdict
...
...
theano/gof/optdb.py
浏览文件 @
de05e842
import
StringIO
import
sys
from
python25
import
DefaultOrderedDict
from
theano.gof.
python25
import
DefaultOrderedDict
import
numpy
import
opt
from
theano.gof
import
opt
from
theano.configparser
import
AddConfigVar
,
FloatParam
from
theano
import
config
AddConfigVar
(
'optdb.position_cutoff'
,
...
...
theano/gof/sched.py
浏览文件 @
de05e842
from
graph
import
list_of_nodes
from
theano.gof.
graph
import
list_of_nodes
from
theano.gof.python25
import
any
,
defaultdict
...
...
theano/gof/toolbox.py
浏览文件 @
de05e842
...
...
@@ -4,7 +4,7 @@ import time
from
theano.gof.python25
import
partial
from
theano.gof.python25
import
OrderedDict
import
graph
from
theano.gof
import
graph
...
...
theano/gof/type.py
浏览文件 @
de05e842
...
...
@@ -2,9 +2,9 @@
__docformat__
=
"restructuredtext en"
import
utils
from
utils
import
MethodNotDefined
,
object2
import
graph
from
theano.gof
import
utils
from
theano.gof.
utils
import
MethodNotDefined
,
object2
from
theano.gof
import
graph
########
# Type #
...
...
theano/gof/unify.py
浏览文件 @
de05e842
...
...
@@ -9,8 +9,8 @@ if there exists an assignment to all unification variables such that
"""
from
copy
import
copy
from
python25
import
partial
from
utils
import
*
from
theano.gof.
python25
import
partial
from
theano.gof.
utils
import
*
################################
...
...
theano/gof/vm.py
浏览文件 @
de05e842
...
...
@@ -11,11 +11,10 @@ import warnings
from
theano.gof.python25
import
all
import
theano
config
=
theano
.
config
from
theano.configparser
import
config
,
AddConfigVar
,
BoolParam
,
ConfigParam
import
theano.gof.cmodule
logger
=
logging
.
getLogger
(
__name__
)
AddConfigVar
(
'profile'
,
...
...
theano/ifelse.py
浏览文件 @
de05e842
...
...
@@ -27,12 +27,12 @@ from theano.gof import PureOp, Apply
import
theano.tensor
from
theano.tensor
import
TensorType
import
gof
from
theano
import
gof
from
compile
import
optdb
from
tensor
import
opt
from
scan_module.scan_utils
import
find_up
from
scan_module.scan_utils
import
clone
from
theano.
compile
import
optdb
from
t
heano.t
ensor
import
opt
from
theano.
scan_module.scan_utils
import
find_up
from
theano.
scan_module.scan_utils
import
clone
_logger
=
logging
.
getLogger
(
'theano.ifelse'
)
...
...
theano/printing.py
浏览文件 @
de05e842
...
...
@@ -24,9 +24,9 @@ except ImportError:
pydot_imported
=
False
import
theano
import
gof
from
theano
import
gof
from
theano
import
config
from
gof
import
Op
,
Apply
from
theano.
gof
import
Op
,
Apply
from
theano.gof.python25
import
any
from
theano.compile
import
Function
,
debugmode
from
theano.compile.profilemode
import
ProfileMode
...
...
theano/raise_op.py
浏览文件 @
de05e842
...
...
@@ -6,7 +6,7 @@ __license__ = "3-clause BSD License"
__contact__
=
"theano-dev <theano-dev@googlegroups.com>"
__docformat__
=
"restructuredtext en"
import
gof
from
theano
import
gof
class
Raise
(
gof
.
Op
):
"""Op whose perform() raises an exception.
...
...
theano/scan_module/__init__.py
浏览文件 @
de05e842
...
...
@@ -38,7 +38,7 @@ __authors__ = ("Razvan Pascanu "
__copyright__
=
"(c) 2010, Universite de Montreal"
__contact__
=
"Razvan Pascanu <r.pascanu@gmail>"
import
scan_opt
from
scan
import
scan
from
scan_views
import
map
,
reduce
,
foldl
,
foldr
from
scan_utils
import
clone
,
until
from
theano.scan_module
import
scan_opt
from
theano.scan_module.
scan
import
scan
from
theano.scan_module.
scan_views
import
map
,
reduce
,
foldl
,
foldr
from
theano.scan_module.
scan_utils
import
clone
,
until
theano/scan_module/scan.py
浏览文件 @
de05e842
...
...
@@ -57,9 +57,9 @@ from theano.compile import ops
from
theano.gof.python25
import
OrderedDict
import
scan_op
import
scan_utils
from
scan_utils
import
safe_new
,
traverse
from
theano.scan_module
import
scan_op
from
theano.scan_module
import
scan_utils
from
theano.scan_module.
scan_utils
import
safe_new
,
traverse
# Logging function for sending warning or info
_logger
=
logging
.
getLogger
(
'theano.scan_module.scan'
)
...
...
theano/scan_module/scan_op.py
浏览文件 @
de05e842
...
...
@@ -33,8 +33,8 @@ from theano.gradient import grad_undefined
from
theano.gradient
import
DisconnectedType
from
theano.compile.profiling
import
ScanProfileStats
import
scan_utils
from
scan_utils
import
safe_new
,
forced_replace
from
theano.scan_module
import
scan_utils
from
theano.scan_module.
scan_utils
import
safe_new
,
forced_replace
# Logging function for sending warning or info
_logger
=
logging
.
getLogger
(
'theano.scan_module.scan_op'
)
...
...
theano/scan_module/scan_opt.py
浏览文件 @
de05e842
...
...
@@ -26,9 +26,9 @@ from theano.gof import toolbox, DestroyHandler, InconsistencyError
from
theano.compile
import
optdb
from
theano.compile.function_module
import
deep_copy_op
import
scan_op
import
scan_utils
from
scan_utils
import
equal_computations
,
find_up
,
scan_args
from
theano.scan_module
import
scan_op
from
theano.scan_module
import
scan_utils
from
theano.scan_module.
scan_utils
import
equal_computations
,
find_up
,
scan_args
from
theano.gof.opt
import
pre_constant_merge
,
pre_greedy_local_optimizer
# Logging function for sending warning or info
...
...
theano/scan_module/scan_views.py
浏览文件 @
de05e842
...
...
@@ -15,7 +15,7 @@ __contact__ = "Razvan Pascanu <r.pascanu@gmail>"
import
logging
import
scan
from
theano.scan_module
import
scan
# Logging function for sending warning or info
_logger
=
logging
.
getLogger
(
'theano.scan_module.scan_views'
)
...
...
@@ -58,7 +58,7 @@ def map(fn,
:param name: See ``scan``.
"""
return
scan
.
scan
(
fn
=
fn
,
return
scan
(
fn
=
fn
,
sequences
=
sequences
,
outputs_info
=
[],
non_sequences
=
non_sequences
,
...
...
@@ -101,7 +101,7 @@ def reduce(fn,
:param name: See ``scan``.
"""
rval
=
scan
.
scan
(
fn
=
fn
,
rval
=
scan
(
fn
=
fn
,
sequences
=
sequences
,
outputs_info
=
outputs_info
,
non_sequences
=
non_sequences
,
...
...
theano/sparse/opt.py
浏览文件 @
de05e842
...
...
@@ -4,13 +4,12 @@ import theano
import
numpy
from
theano
import
gof
,
scalar
,
tensor
from
theano.tensor
import
blas
from
theano.sparse
import
(
CSC
,
CSR
,
csm_properties
,
Remove0
,
from
theano.sparse
import
(
CSC
,
CSR
,
csm_properties
,
register_specialize
,
csm_grad
,
usmm
)
from
theano.sparse
import
basic
as
sparse
from
basic
import
_is_sparse_variable
_is_sparse_variable
=
sparse
.
_is_sparse_variable
# This is tested in tests/test_opt.py:test_local_csm_properties_csm
@gof.local_optimizer
([
csm_properties
])
...
...
theano/sparse/sharedvar.py
浏览文件 @
de05e842
import
copy
import
scipy.sparse
from
theano.compile
import
shared_constructor
,
SharedVariable
from
theano
import
config
from
basic
import
SparseType
,
_sparse_py_operators
from
theano
.sparse.basic
import
SparseType
,
_sparse_py_operators
class
SparseTensorSharedVariable
(
_sparse_py_operators
,
SharedVariable
):
pass
@shared_constructor
def
sparse_constructor
(
value
,
name
=
None
,
strict
=
False
,
allow_downcast
=
None
,
borrow
=
False
,
format
=
None
):
borrow
=
False
,
format
=
None
):
"""SharedVariable Constructor for SparseType
writeme
"""
if
not
isinstance
(
value
,
scipy
.
sparse
.
spmatrix
):
raise
TypeError
(
"Expected a sparse matrix in the sparse shared variable constructor. Received: "
,
value
.
__class__
)
raise
TypeError
(
"Expected a sparse matrix in the sparse shared variable constructor. Received: "
,
value
.
__class__
)
if
format
is
None
:
format
=
value
.
format
type
=
SparseType
(
format
=
format
,
dtype
=
value
.
dtype
)
type
=
SparseType
(
format
=
format
,
dtype
=
value
.
dtype
)
if
not
borrow
:
value
=
copy
.
deepcopy
(
value
)
return
SparseTensorSharedVariable
(
type
=
type
,
value
=
value
,
name
=
name
,
strict
=
strict
,
allow_downcast
=
allow_downcast
)
strict
=
strict
,
allow_downcast
=
allow_downcast
)
theano/tensor/__init__.py
浏览文件 @
de05e842
...
...
@@ -3,34 +3,35 @@ __docformat__ = "restructuredtext en"
import
warnings
from
basic
import
*
from
theano.tensor.
basic
import
*
import
opt
import
opt_uncanonicalize
import
blas
import
blas_scipy
import
blas_c
import
xlogx
from
theano.tensor
import
opt
from
theano.tensor
import
opt_uncanonicalize
from
theano.tensor
import
blas
from
theano.tensor
import
blas_scipy
from
theano.tensor
import
blas_c
from
theano.tensor
import
xlogx
import
raw_random
import
randomstreams
import
shared_randomstreams
from
randomstreams
import
\
RandomStreams
# These imports cannot be performed here because the modules depend on tensor. This is done at the
# end of theano.__init__.py instead.
#from theano.tensor import raw_random
#from theano.tensor import randomstreams
#from theano.tensor import shared_randomstreams
#from theano.tensor.randomstreams import \
# RandomStreams
random
=
RandomStreams
(
seed
=
0xBAD5EED
,
no_warn
=
True
)
"""Imitate the numpy.random symbol with a tensor.random one"""
#
random = RandomStreams(seed=0xBAD5EED, no_warn = True)
#
"""Imitate the numpy.random symbol with a tensor.random one"""
from
elemwise
import
\
DimShuffle
,
Elemwise
,
CAReduce
from
theano.tensor.elemwise
import
DimShuffle
,
Elemwise
,
CAReduce
import
sharedvar
# adds shared-variable constructors
from
theano.tensor
import
sharedvar
# adds shared-variable constructors
# We import as `_shared` instead of `shared` to avoid confusion between
# `theano.shared` and `tensor._shared`.
from
sharedvar
import
tensor_constructor
as
_shared
from
theano.tensor.
sharedvar
import
tensor_constructor
as
_shared
from
io
import
*
from
theano.tensor.
io
import
*
def
shared
(
*
args
,
**
kw
):
"""
...
...
@@ -49,11 +50,11 @@ def shared(*args, **kw):
return
_shared
(
*
args
,
**
kw
)
import
nnet
# used for softmax, sigmoid, etc.
from
theano.tensor
import
nnet
# used for softmax, sigmoid, etc.
from
theano.gradient
import
Rop
,
Lop
,
grad
,
numeric_grad
,
verify_grad
,
\
jacobian
,
hessian
from
theano.tensor.sort
import
sort
,
argsort
from
extra_ops
import
(
DiffOp
,
bincount
,
squeeze
,
from
theano.tensor.
extra_ops
import
(
DiffOp
,
bincount
,
squeeze
,
repeat
,
bartlett
,
fill_diagonal
)
theano/tensor/basic.py
浏览文件 @
de05e842
...
...
@@ -14,7 +14,7 @@ from theano.configparser import config
from
theano
import
gof
from
theano.gof
import
Apply
,
Constant
,
Op
,
Type
,
Variable
import
elemwise
from
theano.tensor
import
elemwise
from
theano
import
scalar
as
scal
from
theano.gof.python25
import
partial
,
any
,
all
,
maxsize
from
theano
import
compile
,
printing
...
...
@@ -29,7 +29,7 @@ from theano.gradient import grad_not_implemented
from
theano.gradient
import
DisconnectedType
### set up the external interface
from
elemwise
import
Elemwise
,
DimShuffle
,
CAReduce
,
Sum
from
theano.tensor.
elemwise
import
Elemwise
,
DimShuffle
,
CAReduce
,
Sum
import
logging
_logger
=
logging
.
getLogger
(
"theano.tensor.basic"
)
...
...
theano/tensor/blas_c.py
浏览文件 @
de05e842
from
theano
import
config
from
blas
import
ldflags
,
blas_header_text
from
blas
import
blas_optdb
,
optdb
,
local_optimizer
,
EquilibriumOptimizer
from
blas
import
Ger
,
ger
,
ger_destructive
from
blas
import
Gemv
,
gemv_inplace
,
gemv_no_inplace
from
theano.tensor.
blas
import
ldflags
,
blas_header_text
from
theano.tensor.
blas
import
blas_optdb
,
optdb
,
local_optimizer
,
EquilibriumOptimizer
from
theano.tensor.
blas
import
Ger
,
ger
,
ger_destructive
from
theano.tensor.
blas
import
Gemv
,
gemv_inplace
,
gemv_no_inplace
class
BaseBLAS
(
object
):
...
...
theano/tensor/elemwise.py
浏览文件 @
de05e842
...
...
@@ -5,7 +5,6 @@ from itertools import izip
import
numpy
import
elemwise_cgen
as
cgen
import
theano
from
theano
import
gof
from
theano.gof
import
Apply
,
Op
...
...
@@ -16,6 +15,7 @@ from theano.gof.python25 import all, any
from
theano.tensor.utils
import
hash_from_dict
from
theano.gradient
import
DisconnectedType
from
theano.gof.null_type
import
NullType
from
theano.tensor
import
elemwise_cgen
as
cgen
config
=
theano
.
config
...
...
theano/tensor/extra_ops.py
浏览文件 @
de05e842
...
...
@@ -2,9 +2,9 @@ import numpy as np
import
numpy
import
theano
import
basic
from
theano.tensor
import
basic
from
theano
import
gof
,
scalar
import
basic
as
tensor
tensor
=
basic
from
theano.gradient
import
DisconnectedType
...
...
theano/tensor/io.py
浏览文件 @
de05e842
...
...
@@ -2,7 +2,7 @@ import numpy
from
theano
import
gof
from
theano.gof
import
Constant
,
Generic
,
Op
from
theano.gof.sched
import
key_to_cmp
from
basic
import
tensor
from
theano.tensor
import
tensor
import
theano
##########################
# Disk Access
...
...
theano/tensor/opt.py
浏览文件 @
de05e842
...
...
@@ -23,9 +23,9 @@ from theano.gof import Variable, Constant
from
theano.gof.python25
import
maxsize
from
theano.gof.utils
import
MethodNotDefined
from
theano.configparser
import
config
from
elemwise
import
Elemwise
,
DimShuffle
from
theano.tensor.
elemwise
import
Elemwise
,
DimShuffle
from
theano
import
scalar
import
basic
as
T
from
theano.tensor
import
basic
as
T
from
theano
import
compile
# to register the optimizer built by this file
from
theano.gof.python25
import
any
,
all
...
...
@@ -33,7 +33,7 @@ from theano.gof.opt import (Optimizer, pre_constant_merge,
pre_greedy_local_optimizer
)
from
theano.gof.opt
import
merge_optimizer
from
theano.gof
import
toolbox
,
DestroyHandler
from
basic
import
get_scalar_constant_value
,
ShapeError
,
NotScalarConstantError
from
theano.tensor.
basic
import
get_scalar_constant_value
,
ShapeError
,
NotScalarConstantError
theano
.
configparser
.
AddConfigVar
(
'on_shape_error'
,
...
...
theano/tensor/opt_uncanonicalize.py
浏览文件 @
de05e842
...
...
@@ -29,13 +29,13 @@ import logging
_logger
=
logging
.
getLogger
(
'theano.tensor.opt'
)
from
theano
import
gof
from
elemwise
import
CAReduce
import
basic
as
T
from
theano.tensor.
elemwise
import
CAReduce
from
theano.tensor
import
basic
as
T
from
theano.gof.opt
import
Optimizer
from
theano.gof
import
InconsistencyError
,
toolbox
from
basic
import
get_scalar_constant_value
,
NotScalarConstantError
from
theano.tensor.
basic
import
get_scalar_constant_value
,
NotScalarConstantError
from
theano.tensor.opt
import
register_uncanonicalize
from
theano
import
scalar
as
scal
...
...
theano/tensor/raw_random.py
浏览文件 @
de05e842
...
...
@@ -7,8 +7,8 @@ import numpy
#local imports
import
theano
import
basic
as
tensor
import
opt
from
theano
import
tensor
from
theano.tensor
import
opt
from
theano
import
gof
from
theano.compile
import
optdb
...
...
theano/tensor/shared_randomstreams.py
浏览文件 @
de05e842
...
...
@@ -8,7 +8,7 @@ import numpy
from
theano.compile.sharedvalue
import
(
SharedVariable
,
shared_constructor
,
shared
)
import
raw_random
from
theano.tensor
import
raw_random
class
RandomStateSharedVariable
(
SharedVariable
):
...
...
theano/tensor/sharedvar.py
浏览文件 @
de05e842
...
...
@@ -3,7 +3,7 @@ import traceback
import
numpy
import
theano.tensor.basic
from
basic
import
TensorType
,
_tensor_py_operators
from
theano.tensor.
basic
import
TensorType
,
_tensor_py_operators
from
theano.compile
import
shared_constructor
,
SharedVariable
...
...
theano/tensor/sort.py
浏览文件 @
de05e842
...
...
@@ -3,7 +3,7 @@ import numpy as np
import
theano
from
theano.tensor
import
tensor
from
basic
import
mul
from
theano.tensor.
basic
import
mul
class
SortOp
(
theano
.
Op
):
...
...
theano/tensor/tests/test_naacl09.py
浏览文件 @
de05e842
...
...
@@ -66,7 +66,7 @@ class QuadraticDenoisingAA(module.Module):
"""
super
(
QuadraticDenoisingAA
,
self
)
.
__init__
()
self
.
random
=
T
.
RandomStreams
()
self
.
random
=
T
.
randomstreams
.
RandomStreams
()
# MODEL CONFIGURATION
# self.regularize = regularize
...
...
theano/tensor/xlogx.py
浏览文件 @
de05e842
import
numpy
from
elemwise
import
Elemwise
from
theano.tensor.
elemwise
import
Elemwise
from
theano
import
scalar
class
XlogX
(
scalar
.
UnaryScalarOp
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论