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

Fix imports for Python 3k.

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