提交 a2ec954c authored 作者: abalkin's avatar abalkin

Issue #783: python3 compatible - remove unnecessary imports.

This commit is the first step of the plan to make Theano imports compatible with 3.x: 1. Remove unnecessary imports. 2. Convert relative imports to absolute. 3. Fix circular dependency issues by either eliminating "from xyz" imports or moving them inside functions.
上级 5a421ca3
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
""" """
__docformat__ = "restructuredtext en" __docformat__ = "restructuredtext en"
import time, copy, sys, copy_reg, gc, os import copy, sys, copy_reg, gc
from itertools import izip from itertools import izip
from StringIO import StringIO from StringIO import StringIO
......
...@@ -3,13 +3,10 @@ ...@@ -3,13 +3,10 @@
__docformat__ = "restructuredtext en" __docformat__ = "restructuredtext en"
import logging import logging
import sys
import traceback
_logger = logging.getLogger('theano.compile.function') _logger = logging.getLogger('theano.compile.function')
from io import In from io import In
from function_module import orig_function from function_module import orig_function
from profiling import ProfileStats
from pfunc import pfunc from pfunc import pfunc
from numpy import any # to work in python 2.4 from numpy import any # to work in python 2.4
import warnings import warnings
......
...@@ -9,7 +9,7 @@ from theano import config ...@@ -9,7 +9,7 @@ from theano import config
from theano.compile import orig_function, In, Out from theano.compile import orig_function, In, Out
from theano.compile import UnusedInputError from theano.compile import UnusedInputError
from theano.compile.sharedvalue import SharedVariable, shared from theano.compile.sharedvalue import SharedVariable, shared
from theano.gof import Container, Variable, generic, graph, Constant from theano.gof import Variable, Constant
from theano.gof.python25 import any from theano.gof.python25 import any
import logging import logging
......
import cPickle, logging, sys import cPickle, logging
_logger=logging.getLogger("theano.gof.callcache") _logger=logging.getLogger("theano.gof.callcache")
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
# same compilation directory (which can cause crashes). # same compilation directory (which can cause crashes).
from theano import config from theano import config
import compiledir
import os, random, time, atexit import os, random, time, atexit
import socket # only used for gethostname() import socket # only used for gethostname()
import logging import logging
......
...@@ -2,12 +2,6 @@ ...@@ -2,12 +2,6 @@
Classes and functions for validating graphs that contain view Classes and functions for validating graphs that contain view
and inplace operations. and inplace operations.
""" """
import sys
if sys.version_info[:2] >= (2,5):
from collections import defaultdict
# otherwise it's implemented in python25.py
import theano import theano
import toolbox import toolbox
import graph import graph
......
...@@ -12,7 +12,6 @@ from python25 import all ...@@ -12,7 +12,6 @@ from python25 import all
from theano import config from theano import config
import warnings import warnings
NullType = None NullType = None
import theano
from python25 import OrderedDict from python25 import OrderedDict
from theano.misc.ordered_set import OrderedSet from theano.misc.ordered_set import OrderedSet
......
...@@ -2,11 +2,9 @@ ...@@ -2,11 +2,9 @@
__docformat__ = "restructuredtext en" __docformat__ = "restructuredtext en"
import copy
import utils import utils
from utils import MethodNotDefined, object2 from utils import MethodNotDefined, object2
import graph import graph
from theano import config
######## ########
# Type # # Type #
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# import variable # import variable
from theano import config from theano import config
import re, os, traceback import re, traceback
def add_tag_trace(thing): def add_tag_trace(thing):
"""Add tag.trace to an node or variable. """Add tag.trace to an node or variable.
......
...@@ -21,10 +21,8 @@ from itertools import izip ...@@ -21,10 +21,8 @@ from itertools import izip
from theano import gof from theano import gof
from theano.gof import Variable from theano.gof import Variable
from theano.gof.python25 import OrderedDict from theano.gof.python25 import OrderedDict
from theano.gof.python25 import all
import theano.gof.utils
from theano.gof.null_type import NullType from theano.gof.null_type import NullType
from theano.printing import min_informative_str
# we can't do "import theano.tensor" # we can't do "import theano.tensor"
# tensor depends on theano.compile # tensor depends on theano.compile
# theano.compile depends on theano.gradient (this file) # theano.compile depends on theano.gradient (this file)
......
# This is work in progress # This is work in progress
import theano
from theano import Op, Apply from theano import Op, Apply
import theano.tensor as T
from theano.gof import local_optimizer from theano.gof import local_optimizer
from theano.sandbox.cuda import cuda_available, GpuOp from theano.sandbox.cuda import cuda_available, GpuOp
......
import numpy
import theano import theano
from theano.gof import Op, Apply from theano.gof import Op, Apply
from theano import tensor from theano import tensor
......
...@@ -12,7 +12,7 @@ from theano.tensor.opt import (register_stabilize, ...@@ -12,7 +12,7 @@ from theano.tensor.opt import (register_stabilize,
register_specialize, register_canonicalize) register_specialize, register_canonicalize)
from theano.gof import local_optimizer from theano.gof import local_optimizer
from theano.gof.opt import Optimizer from theano.gof.opt import Optimizer
from theano.gradient import grad_not_implemented, DisconnectedType from theano.gradient import DisconnectedType
try: try:
import scipy.linalg import scipy.linalg
......
...@@ -12,27 +12,18 @@ __authors__ = ("Razvan Pascanu " ...@@ -12,27 +12,18 @@ __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>"
import itertools
import logging import logging
import time
from itertools import izip from itertools import izip
import numpy import numpy
import theano import theano
from theano.compile import function, Param, Out
from theano import compile from theano import compile
from theano import gradient
from theano.gof.python25 import any from theano.gof.python25 import any
from theano.gof import PureOp, Apply from theano.gof import PureOp, Apply
from theano import gof from theano import gof
from theano.tensor import TensorType from theano.tensor import TensorType
from theano import tensor
from theano.tensor.opt import Shape_i from theano.tensor.opt import Shape_i
#from theano.sandbox import cuda
from theano.compile.profiling import ScanProfileStats
import scan_utils
# Logging function for sending warning or info # Logging function for sending warning or info
_logger = logging.getLogger('theano.scan_module.scan_op') _logger = logging.getLogger('theano.scan_module.scan_op')
......
...@@ -22,7 +22,7 @@ __contact__ = "theano-dev <theano-dev@googlegroups.com>" ...@@ -22,7 +22,7 @@ __contact__ = "theano-dev <theano-dev@googlegroups.com>"
__docformat__ = "restructuredtext en" __docformat__ = "restructuredtext en"
import numpy import numpy
from theano.compile import shared_constructor, 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):
......
import theano
import numpy import numpy
import math import math
from theano import gof, tensor, function, scalar from theano import gof, tensor
from theano.sandbox.linalg.ops import diag
class Fourier(gof.Op): class Fourier(gof.Op):
......
from basic import _scal_elemwise #, _transpose_inplace
from theano import scalar as scal from theano import scalar as scal
import elemwise import elemwise
from theano import printing from theano import printing
from theano.printing import pprint from theano.printing import pprint
from theano.gof.python25 import any
def _scal_inplace(symbol): def _scal_inplace(symbol):
"""Replace a symbol definition with an elementwise version of the corresponding scalar Op""" """Replace a symbol definition with an elementwise version of the corresponding scalar Op"""
......
...@@ -28,16 +28,10 @@ Also, we should make the fgraph refuse optimization that break the canonization ...@@ -28,16 +28,10 @@ Also, we should make the fgraph refuse optimization that break the canonization
import logging import logging
_logger = logging.getLogger('theano.tensor.opt') _logger = logging.getLogger('theano.tensor.opt')
import operator
import itertools
import sys
import theano
from theano import gof from theano import gof
from elemwise import CAReduce from elemwise import CAReduce
import basic as T import basic as T
from theano.gof.python25 import any, all
from theano.gof.opt import Optimizer from theano.gof.opt import Optimizer
from theano.gof import InconsistencyError, toolbox from theano.gof import InconsistencyError, toolbox
......
...@@ -4,11 +4,8 @@ graphs. ...@@ -4,11 +4,8 @@ graphs.
__docformat__ = "restructuredtext en" __docformat__ = "restructuredtext en"
import copy import copy
import sys
import numpy import numpy
from theano.gof import Container
from theano.compile.sharedvalue import (SharedVariable, shared_constructor, from theano.compile.sharedvalue import (SharedVariable, shared_constructor,
shared) shared)
import raw_random import raw_random
......
...@@ -5,11 +5,7 @@ generic 2D convolution. ...@@ -5,11 +5,7 @@ generic 2D convolution.
__docformat__ = "restructuredtext en" __docformat__ = "restructuredtext en"
import numpy
import theano
import theano.tensor as tensor import theano.tensor as tensor
import theano.tensor.nnet as nnet
from theano import gof, Op, tensor, config
from theano.tensor.nnet import conv from theano.tensor.nnet import conv
import logging import logging
......
import theano
import numpy import numpy
from elemwise import Elemwise from elemwise import Elemwise
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论