提交 0162c1d9 authored 作者: David Warde-Farley's avatar David Warde-Farley 提交者: Arnaud Bergeron

Fix imports for Python 3k.

上级 d0c3feb7
"""Define `SymbolicInput`, `SymbolicOutput`, `In`, `Out` """ """Define `SymbolicInput`, `SymbolicOutput`, `In`, `Out` """
from theano import gof from theano import gof
from sharedvalue import SharedVariable from .sharedvalue import SharedVariable
import logging import logging
_logger = logging.getLogger("theano.compile.io") _logger = logging.getLogger("theano.compile.io")
......
...@@ -359,13 +359,13 @@ def get_mode(orig_string): ...@@ -359,13 +359,13 @@ def get_mode(orig_string):
if string in ['Mode', 'ProfileMode', 'DebugMode']: if string in ['Mode', 'ProfileMode', 'DebugMode']:
if string == 'DebugMode': if string == 'DebugMode':
# need to import later to break circular dependency. # need to import later to break circular dependency.
from debugmode import DebugMode from .debugmode import DebugMode
# DebugMode use its own linker. # DebugMode use its own linker.
ret = DebugMode(optimizer=config.optimizer) ret = DebugMode(optimizer=config.optimizer)
else: else:
# This might be required if the string is 'ProfileMode' # This might be required if the string is 'ProfileMode'
from profilemode import ProfileMode # noqa from .profilemode import ProfileMode # noqa
from profilemode import prof_mode_instance_to_print from .profilemode import prof_mode_instance_to_print
ret = eval(string + ret = eval(string +
'(linker=config.linker, optimizer=config.optimizer)') '(linker=config.linker, optimizer=config.optimizer)')
elif string in predefined_modes: elif string in predefined_modes:
......
...@@ -13,7 +13,7 @@ from theano.compile.mode import (Mode, register_mode, ...@@ -13,7 +13,7 @@ from theano.compile.mode import (Mode, register_mode,
from theano.configparser import config, AddConfigVar, IntParam, BoolParam from theano.configparser import config, AddConfigVar, IntParam, BoolParam
from theano.compile.function_module import FunctionMaker from theano.compile.function_module import FunctionMaker
from profiling import ProfileStats from .profiling import ProfileStats
run_cthunk = None # Will be imported only when needed. run_cthunk = None # Will be imported only when needed.
import_time = time.time() import_time = time.time()
......
...@@ -5,7 +5,7 @@ import sys ...@@ -5,7 +5,7 @@ import sys
from theano.compat import PY3 from theano.compat import PY3
from theano.gof.compilelock import get_lock, release_lock from theano.gof.compilelock import get_lock, release_lock
from theano import config from theano import config
import cmodule from . import cmodule
# TODO These two lines may be removed in the future, when we are 100% sure # TODO These two lines may be removed in the future, when we are 100% sure
# noone has an old cutils_ext.so lying around anymore. # noone has an old cutils_ext.so lying around anymore.
......
...@@ -3,12 +3,12 @@ Classes and functions for validating graphs that contain view ...@@ -3,12 +3,12 @@ Classes and functions for validating graphs that contain view
and inplace operations. and inplace operations.
""" """
import theano import theano
import toolbox from . import toolbox
import graph from . import graph
from theano.compat import deque, OrderedDict from theano.compat import deque, OrderedDict
from theano.misc.ordered_set import OrderedSet from theano.misc.ordered_set import OrderedSet
from fg import InconsistencyError from .fg import InconsistencyError
class ProtocolError(Exception): class ProtocolError(Exception):
......
...@@ -248,7 +248,7 @@ class FunctionGraph(utils.object2): ...@@ -248,7 +248,7 @@ class FunctionGraph(utils.object2):
def __import_r__(self, variable, reason): def __import_r__(self, variable, reason):
global NullType global NullType
if NullType is None: if NullType is None:
from null_type import NullType from .null_type import NullType
# Imports the owners of the variables # Imports the owners of the variables
if variable.owner and variable.owner not in self.apply_nodes: if variable.owner and variable.owner not in self.apply_nodes:
self.__import__(variable.owner, reason=reason) self.__import__(variable.owner, reason=reason)
......
...@@ -10,6 +10,7 @@ from theano import config ...@@ -10,6 +10,7 @@ from theano import config
from theano.compat import reload from theano.compat import reload
from theano.gof.compilelock import get_lock, release_lock from theano.gof.compilelock import get_lock, release_lock
from theano.gof import cmodule from theano.gof import cmodule
import imp
_logger = logging.getLogger('theano.gof.lazylinker_c') _logger = logging.getLogger('theano.gof.lazylinker_c')
...@@ -27,7 +28,7 @@ def try_import(): ...@@ -27,7 +28,7 @@ def try_import():
def try_reload(): def try_reload():
sys.path[0:0] = [config.compiledir] sys.path[0:0] = [config.compiledir]
reload(lazylinker_ext) imp.reload(lazylinker_ext)
del sys.path[0] del sys.path[0]
try: try:
......
...@@ -3,7 +3,7 @@ VMs that run Theano graph computations. ...@@ -3,7 +3,7 @@ VMs that run Theano graph computations.
A VM is not actually different from a Linker, we just decided A VM is not actually different from a Linker, we just decided
VM was a better name at some point. VM was a better name at some point.
""" """
import link from . import link
import logging import logging
import os import os
import sys import sys
...@@ -661,7 +661,7 @@ class Stack(VM): ...@@ -661,7 +661,7 @@ class Stack(VM):
try: try:
import lazylinker_c from . import lazylinker_c
class CVM(lazylinker_c.CLazyLinker, VM): class CVM(lazylinker_c.CLazyLinker, VM):
......
...@@ -31,7 +31,7 @@ from theano.sandbox.cuda.basic_ops import (as_cuda_ndarray_variable, ...@@ -31,7 +31,7 @@ from theano.sandbox.cuda.basic_ops import (as_cuda_ndarray_variable,
from theano.sandbox.cuda.opt import gpu_seqopt from theano.sandbox.cuda.opt import gpu_seqopt
from theano.tensor.utils import hash_from_dict from theano.tensor.utils import hash_from_dict
import pycuda_init from . import pycuda_init
if not pycuda_init.pycuda_available: if not pycuda_init.pycuda_available:
raise Exception("No pycuda available. You can't load pycuda_example.py") raise Exception("No pycuda available. You can't load pycuda_example.py")
......
...@@ -14,7 +14,7 @@ from theano.gof import EquilibriumDB, SequenceDB ...@@ -14,7 +14,7 @@ from theano.gof import EquilibriumDB, SequenceDB
from theano.gof.cmodule import get_lib_extension from theano.gof.cmodule import get_lib_extension
from theano.gof.compilelock import get_lock, release_lock from theano.gof.compilelock import get_lock, release_lock
from theano.configparser import config, AddConfigVar, StrParam, BoolParam from theano.configparser import config, AddConfigVar, StrParam, BoolParam
import nvcc_compiler from . import nvcc_compiler
# ignore_newtrees is to speed the optimization as this is the pattern # ignore_newtrees is to speed the optimization as this is the pattern
# we use for optimization. Otherwise, we can iterate 100s of time on # we use for optimization. Otherwise, we can iterate 100s of time on
......
...@@ -296,7 +296,7 @@ class GpuArrayType(Type): ...@@ -296,7 +296,7 @@ class GpuArrayType(Type):
class _operators(_tensor_py_operators): class _operators(_tensor_py_operators):
def _as_TensorVariable(self): def _as_TensorVariable(self):
from basic_ops import host_from_gpu from .basic_ops import host_from_gpu
return host_from_gpu(self) return host_from_gpu(self)
def _as_GpuArrayVariable(self): def _as_GpuArrayVariable(self):
......
from ops import (cholesky, matrix_inverse, solve, from .ops import (cholesky, matrix_inverse, solve,
diag, extract_diag, alloc_diag, diag, extract_diag, alloc_diag,
det, psd, eig, eigh, eigvalsh, det, psd, eig, eigh, eigvalsh,
trace, spectral_radius_bound) trace, spectral_radius_bound)
...@@ -19,7 +19,7 @@ from theano.tensor import sqrt, log, sin, cos, join, prod ...@@ -19,7 +19,7 @@ from theano.tensor import sqrt, log, sin, cos, join, prod
from theano.compile import optdb from theano.compile import optdb
from theano.gof import local_optimizer from theano.gof import local_optimizer
import multinomial from . import multinomial
from theano.sandbox.cuda import cuda_available, cuda_enabled, GpuOp from theano.sandbox.cuda import cuda_available, cuda_enabled, GpuOp
if cuda_available: if cuda_available:
......
...@@ -38,4 +38,4 @@ __authors__ = ("Razvan Pascanu " ...@@ -38,4 +38,4 @@ __authors__ = ("Razvan Pascanu "
__copyright__ = "(c) 2010, Universite de Montreal" __copyright__ = "(c) 2010, Universite de Montreal"
__contact__ = "Razvan Pascanu <r.pascanu@gmail>" __contact__ = "Razvan Pascanu <r.pascanu@gmail>"
from scan import scan from .scan import scan
...@@ -53,8 +53,8 @@ from theano import tensor ...@@ -53,8 +53,8 @@ from theano import tensor
from theano.scalar.sharedvar import shared as scalar_shared from theano.scalar.sharedvar import shared as scalar_shared
from theano.compile.pfunc import rebuild_collect_shared from theano.compile.pfunc import rebuild_collect_shared
import scan_op from . import scan_op
import scan_utils from . import scan_utils
# Logging function for sending warning or info # Logging function for sending warning or info
_logger = logging.getLogger('theano.scan_module.scan') _logger = logging.getLogger('theano.scan_module.scan')
......
...@@ -17,7 +17,7 @@ from theano.compile.pfunc import rebuild_collect_shared ...@@ -17,7 +17,7 @@ from theano.compile.pfunc import rebuild_collect_shared
from theano.tests import unittest_tools as utt from theano.tests import unittest_tools as utt
from numpy.testing.noseclasses import KnownFailureTest from numpy.testing.noseclasses import KnownFailureTest
from test_utils import * from .test_utils import *
import theano.sandbox.scan_module as scan_module import theano.sandbox.scan_module as scan_module
from theano.sandbox.scan_module.scan_op import ScanOp from theano.sandbox.scan_module.scan_op import ScanOp
......
...@@ -4,7 +4,7 @@ import numpy ...@@ -4,7 +4,7 @@ import numpy
import theano import theano
from theano import config, function, tensor from theano import config, function, tensor
import multinomial from . import multinomial
from theano.compile.mode import get_default_mode, predefined_linkers from theano.compile.mode import get_default_mode, predefined_linkers
import theano.sandbox.cuda as cuda import theano.sandbox.cuda as cuda
......
import theano import theano
import numpy import numpy
import scan from . import scan
def test_001(): def test_001():
......
from __future__ import print_function from __future__ import print_function
from theano_object import * from .theano_object import *
RUN_TESTS = False RUN_TESTS = False
......
from basic import * from .basic import *
from basic_scipy import * from .basic_scipy import *
...@@ -23,7 +23,7 @@ __docformat__ = "restructuredtext en" ...@@ -23,7 +23,7 @@ __docformat__ = "restructuredtext en"
import numpy import numpy
from theano.compile import SharedVariable from theano.compile import SharedVariable
from basic import Scalar, _scalar_py_operators from .basic import Scalar, _scalar_py_operators
class ScalarSharedVariable(_scalar_py_operators, SharedVariable): class ScalarSharedVariable(_scalar_py_operators, SharedVariable):
......
...@@ -804,7 +804,7 @@ class Scan(PureOp): ...@@ -804,7 +804,7 @@ class Scan(PureOp):
cython_destroy_map = [0 for x in xrange(len(node.outputs))] cython_destroy_map = [0 for x in xrange(len(node.outputs))]
cython_destroy_map = numpy.asarray(cython_destroy_map, cython_destroy_map = numpy.asarray(cython_destroy_map,
dtype='int32') dtype='int32')
import scan_perform_ext from . import scan_perform_ext
p = lambda node, args, outs:\ p = lambda node, args, outs:\
scan_perform_ext.perform( scan_perform_ext.perform(
self.n_shared_outs, self.n_shared_outs,
......
...@@ -11,6 +11,7 @@ from theano import config ...@@ -11,6 +11,7 @@ from theano import config
from theano.compat import reload from theano.compat import reload
from theano.gof.compilelock import get_lock, release_lock from theano.gof.compilelock import get_lock, release_lock
from theano.gof import cmodule from theano.gof import cmodule
import imp
_logger = logging.getLogger('theano.scan_module.scan_perform') _logger = logging.getLogger('theano.scan_module.scan_perform')
...@@ -30,7 +31,7 @@ def try_import(): ...@@ -30,7 +31,7 @@ def try_import():
def try_reload(): def try_reload():
sys.path[0:0] = [config.compiledir] sys.path[0:0] = [config.compiledir]
reload(scan_perform) imp.reload(scan_perform)
del sys.path[0] del sys.path[0]
try: try:
......
from theano import scalar as scal from theano import scalar as scal
import elemwise from . import elemwise
from theano import printing from theano import printing
from theano.printing import pprint from theano.printing import pprint
......
...@@ -623,5 +623,5 @@ def computeH(V, W, b, d): ...@@ -623,5 +623,5 @@ def computeH(V, W, b, d):
return H return H
import ConvGrad3D from . import ConvGrad3D
import ConvTransp3D from . import ConvTransp3D
from nnet import * from .nnet import *
from conv import conv2d, ConvOp from .conv import conv2d, ConvOp
from Conv3D import * from .Conv3D import *
from ConvGrad3D import * from .ConvGrad3D import *
from ConvTransp3D import * from .ConvTransp3D import *
from sigm import (softplus, sigmoid, sigmoid_inplace, from .sigm import (softplus, sigmoid, sigmoid_inplace,
scalar_sigmoid, ultra_fast_sigmoid, scalar_sigmoid, ultra_fast_sigmoid,
hard_sigmoid) hard_sigmoid)
...@@ -20,7 +20,7 @@ from theano.tensor.blas import (_dot22, _dot22scalar, res_is_a, _as_scalar, ...@@ -20,7 +20,7 @@ from theano.tensor.blas import (_dot22, _dot22scalar, res_is_a, _as_scalar,
gemm_inplace, gemm_no_inplace, gemm_inplace, gemm_no_inplace,
InconsistencyError, Ger, ger, ger_destructive) InconsistencyError, Ger, ger, ger_destructive)
from theano.tests import unittest_tools from theano.tests import unittest_tools
from test_basic import (as_tensor_variable, inplace_func, from .test_basic import (as_tensor_variable, inplace_func,
compile, inplace) compile, inplace)
import theano.tensor.blas_scipy import theano.tensor.blas_scipy
......
...@@ -4,7 +4,7 @@ import theano ...@@ -4,7 +4,7 @@ import theano
import theano.tensor as tensor import theano.tensor as tensor
from theano.tensor.blas_scipy import ScipyGer from theano.tensor.blas_scipy import ScipyGer
from test_blas import TestCase, gemm_no_inplace, TestBlasStrides from .test_blas import TestCase, gemm_no_inplace, TestBlasStrides
from theano.tests.unittest_tools import TestOptimizationMixin from theano.tests.unittest_tools import TestOptimizationMixin
......
...@@ -4,7 +4,7 @@ import unittest ...@@ -4,7 +4,7 @@ import unittest
import theano import theano
from theano.tensor import as_tensor_variable from theano.tensor import as_tensor_variable
import test_basic as TT from . import test_basic as TT
import random import random
import numpy.random import numpy.random
......
from type import TypedListType from .type import TypedListType
from basic import * from .basic import *
import opt from . import opt
...@@ -2,7 +2,7 @@ import copy ...@@ -2,7 +2,7 @@ import copy
import numpy import numpy
from type import TypedListType from .type import TypedListType
import theano import theano
from theano.gof import Apply, Constant, Op, Variable from theano.gof import Apply, Constant, Op, Variable
from theano.tensor.type_other import SliceType from theano.tensor.type_other import SliceType
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论