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

izip/imap/ifilter to theano.compat.

上级 95c9d036
...@@ -11,6 +11,9 @@ __all__ = ['PY3', 'b', 'BytesIO', 'next', 'configparser', 'reload'] ...@@ -11,6 +11,9 @@ __all__ = ['PY3', 'b', 'BytesIO', 'next', 'configparser', 'reload']
if PY3: if PY3:
from operator import truediv as operator_div from operator import truediv as operator_div
izip = zip
imap = map
ifilter = filter
# In python 3.x, when an exception is reraised it saves original # In python 3.x, when an exception is reraised it saves original
# exception in its args, therefore in order to find the actual # exception in its args, therefore in order to find the actual
...@@ -50,6 +53,7 @@ if PY3: ...@@ -50,6 +53,7 @@ if PY3:
else: else:
from theano.compat.six import get_unbound_function from theano.compat.six import get_unbound_function
from operator import div as operator_div from operator import div as operator_div
from itertools import izip, imap, ifilter
def exc_message(e): def exc_message(e):
return e[0] return e[0]
......
...@@ -163,7 +163,8 @@ if sys.version_info[:2] < (2, 7): ...@@ -163,7 +163,8 @@ if sys.version_info[:2] < (2, 7):
from operator import itemgetter from operator import itemgetter
from heapq import nlargest from heapq import nlargest
from itertools import repeat, ifilter from itertools import repeat
from theano.compat import ifilter
class Counter(dict): class Counter(dict):
'''Dict subclass for counting hashable objects. '''Dict subclass for counting hashable objects.
......
...@@ -10,7 +10,8 @@ import sys ...@@ -10,7 +10,8 @@ import sys
import gc import gc
import logging import logging
import theano.compat.six.moves.copyreg as copyreg import theano.compat.six.moves.copyreg as copyreg
from itertools import izip, product as itertools_product from itertools import product as itertools_product
from theano.compat import izip
import numpy import numpy
......
...@@ -14,6 +14,7 @@ import numpy ...@@ -14,6 +14,7 @@ import numpy
import theano import theano
from theano import gof from theano import gof
from functools import partial from functools import partial
from theano.compat import izip
from theano.compat.six import string_types from theano.compat.six import string_types
from theano.compat.six.moves import xrange from theano.compat.six.moves import xrange
import theano.compile.mode import theano.compile.mode
...@@ -559,7 +560,7 @@ returned directly?""" ...@@ -559,7 +560,7 @@ returned directly?"""
is_aliased = False is_aliased = False
for j in xrange(len(args_share_memory)): for j in xrange(len(args_share_memory)):
group_j = itertools.izip( group_j = izip(
[self.maker.inputs[k].variable for k [self.maker.inputs[k].variable for k
in args_share_memory[j]], in args_share_memory[j]],
[self.input_storage[k].storage[0] for k [self.input_storage[k].storage[0] for k
...@@ -693,7 +694,7 @@ returned directly?""" ...@@ -693,7 +694,7 @@ returned directly?"""
assert len(self.output_keys) == len(outputs) assert len(self.output_keys) == len(outputs)
return dict(itertools.izip(self.output_keys, outputs)) return dict(izip(self.output_keys, outputs))
return outputs return outputs
......
...@@ -7,7 +7,7 @@ from __future__ import print_function ...@@ -7,7 +7,7 @@ from __future__ import print_function
from copy import copy from copy import copy
import os import os
import sys import sys
from itertools import izip from theano.compat import izip
import numpy import numpy
......
"""Driver for gradient calculations.""" """Driver for gradient calculations."""
from __future__ import print_function from __future__ import print_function
import theano.compat.six.moves.builtins as builtins import theano.compat.six.moves.builtins as builtins
from itertools import izip from theano.compat import izip
import logging import logging
import time import time
import warnings import warnings
......
...@@ -12,7 +12,7 @@ is a global operation with a scalar condition. ...@@ -12,7 +12,7 @@ is a global operation with a scalar condition.
""" """
from __future__ import print_function from __future__ import print_function
from copy import deepcopy from copy import deepcopy
from itertools import izip from theano.compat import izip
import logging import logging
import numpy import numpy
......
...@@ -2,7 +2,7 @@ from __future__ import print_function ...@@ -2,7 +2,7 @@ from __future__ import print_function
import copy import copy
import logging import logging
import time import time
from itertools import izip from theano.compat import izip
from nose.plugins.skip import SkipTest from nose.plugins.skip import SkipTest
import numpy import numpy
......
from __future__ import print_function from __future__ import print_function
import copy import copy
from itertools import izip from theano.compat import izip
import numpy import numpy
import theano import theano
......
import unittest import unittest
from itertools import izip from theano.compat import izip
from copy import copy, deepcopy from copy import copy, deepcopy
import numpy import numpy
......
...@@ -10,7 +10,6 @@ __copyright__ = "(c) 2010, Universite de Montreal" ...@@ -10,7 +10,6 @@ __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 numpy import numpy
import warnings import warnings
...@@ -19,7 +18,7 @@ from theano.compile import SharedVariable, function ...@@ -19,7 +18,7 @@ from theano.compile import SharedVariable, function
from theano.compat.six import iteritems from theano.compat.six import iteritems
from theano import compile from theano import compile
from theano import gof from theano import gof
from theano.compat import OrderedDict from theano.compat import OrderedDict, ifilter
from theano.tensor import opt from theano.tensor import opt
from theano import tensor from theano import tensor
from theano import config from theano import config
...@@ -460,7 +459,7 @@ def scan(fn, ...@@ -460,7 +459,7 @@ def scan(fn,
fake_outputs = scan_utils.clone(outputs + updates.values(), fake_outputs = scan_utils.clone(outputs + updates.values(),
replace=dict(zip(non_seqs, replace=dict(zip(non_seqs,
fake_nonseqs))) fake_nonseqs)))
all_inputs = itertools.ifilter( all_inputs = ifilter(
lambda x: (isinstance(x, gof.Variable) and lambda x: (isinstance(x, gof.Variable) and
not isinstance(x, SharedVariable) and not isinstance(x, SharedVariable) and
not isinstance(x, gof.Constant)), not isinstance(x, gof.Constant)),
......
...@@ -42,11 +42,11 @@ __copyright__ = "(c) 2010, Universite de Montreal" ...@@ -42,11 +42,11 @@ __copyright__ = "(c) 2010, Universite de Montreal"
__contact__ = "Razvan Pascanu <r.pascanu@gmail>" __contact__ = "Razvan Pascanu <r.pascanu@gmail>"
from itertools import izip
import logging import logging
import numpy import numpy
from theano import gof from theano import gof
from theano.compat import izip
from theano.tensor import opt, TensorVariable from theano.tensor import opt, TensorVariable
from theano.tensor.sharedvar import TensorSharedVariable from theano.tensor.sharedvar import TensorSharedVariable
from theano import tensor from theano import tensor
......
...@@ -14,12 +14,12 @@ __copyright__ = "(c) 2010, Universite de Montreal" ...@@ -14,12 +14,12 @@ __copyright__ = "(c) 2010, Universite de Montreal"
__contact__ = "Razvan Pascanu <r.pascanu@gmail>" __contact__ = "Razvan Pascanu <r.pascanu@gmail>"
import logging import logging
from itertools import izip
import numpy import numpy
import theano import theano
from theano import compile from theano import compile
from theano.compat import izip
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
......
...@@ -17,11 +17,11 @@ __contact__ = "Razvan Pascanu <r.pascanu@gmail>" ...@@ -17,11 +17,11 @@ __contact__ = "Razvan Pascanu <r.pascanu@gmail>"
import copy import copy
import logging import logging
import warnings import warnings
from itertools import izip
import numpy import numpy
import theano import theano
from theano.compat import izip
from theano.compile.pfunc import rebuild_collect_shared from theano.compile.pfunc import rebuild_collect_shared
from theano import gof from theano import gof
from theano import tensor, scalar from theano import tensor, scalar
......
...@@ -16,13 +16,12 @@ from __future__ import print_function ...@@ -16,13 +16,12 @@ from __future__ import print_function
import math import math
import warnings import warnings
from copy import copy from copy import copy
from itertools import imap
from textwrap import dedent from textwrap import dedent
import numpy import numpy
import theano import theano
from theano.compat import PY3 from theano.compat import PY3, imap
from theano import gof, printing from theano import gof, printing
from theano.gof import (Op, utils, Variable, Constant, Type, Apply, from theano.gof import (Op, utils, Variable, Constant, Type, Apply,
FunctionGraph) FunctionGraph)
......
...@@ -42,11 +42,11 @@ __copyright__ = "(c) 2010, Universite de Montreal" ...@@ -42,11 +42,11 @@ __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 numpy import numpy
import warnings import warnings
from theano.compat import ifilter
from theano.compat.six import iteritems from theano.compat.six import iteritems
from theano.compile import SharedVariable, function from theano.compile import SharedVariable, function
from theano import compile from theano import compile
...@@ -792,7 +792,7 @@ def scan(fn, ...@@ -792,7 +792,7 @@ def scan(fn,
fake_outputs = scan_utils.clone(outputs, fake_outputs = scan_utils.clone(outputs,
replace=OrderedDict(zip(non_seqs, replace=OrderedDict(zip(non_seqs,
fake_nonseqs))) fake_nonseqs)))
all_inputs = itertools.ifilter( all_inputs = ifilter(
lambda x: (isinstance(x, gof.Variable) and lambda x: (isinstance(x, gof.Variable) and
not isinstance(x, SharedVariable) and not isinstance(x, SharedVariable) and
not isinstance(x, gof.Constant)), not isinstance(x, gof.Constant)),
......
...@@ -58,7 +58,6 @@ __contact__ = "Razvan Pascanu <r.pascanu@gmail>" ...@@ -58,7 +58,6 @@ __contact__ = "Razvan Pascanu <r.pascanu@gmail>"
import itertools import itertools
import logging import logging
import time import time
from itertools import izip
import numpy import numpy
...@@ -68,7 +67,7 @@ from theano.compile import function, Param, Out ...@@ -68,7 +67,7 @@ from theano.compile import function, Param, Out
from theano import compile, config, gradient, gof, tensor from theano import compile, config, gradient, gof, tensor
from theano.gof import PureOp, Apply from theano.gof import PureOp, Apply
from theano.gof.graph import io_toposort from theano.gof.graph import io_toposort
from theano.compat import OrderedDict from theano.compat import OrderedDict, izip
from theano.tensor import TensorType from theano.tensor import TensorType
from theano.tensor.opt import Shape_i from theano.tensor.opt import Shape_i
from theano.gradient import grad_undefined, DisconnectedType, NullType from theano.gradient import grad_undefined, DisconnectedType, NullType
......
...@@ -16,11 +16,11 @@ __contact__ = "Razvan Pascanu <r.pascanu@gmail>" ...@@ -16,11 +16,11 @@ __contact__ = "Razvan Pascanu <r.pascanu@gmail>"
import copy import copy
import logging import logging
import warnings import warnings
from itertools import izip
import numpy import numpy
import theano import theano
from theano.compat import izip
from theano.compat.six import string_types, iteritems from theano.compat.six import string_types, iteritems
from theano.compile.pfunc import rebuild_collect_shared from theano.compile.pfunc import rebuild_collect_shared
from theano import gof, compat from theano import gof, compat
......
from itertools import izip
import numpy import numpy
import scipy import scipy
import theano import theano
from theano import gof, scalar, tensor from theano import gof, scalar, tensor
from theano.compat import izip
from theano.tensor import blas from theano.tensor import blas
from theano.tensor.opt import register_specialize, register_canonicalize from theano.tensor.opt import register_specialize, register_canonicalize
from theano.sparse import (CSC, CSR, csm_properties, from theano.sparse import (CSC, CSR, csm_properties,
......
...@@ -4,11 +4,11 @@ __docformat__ = "restructuredtext en" ...@@ -4,11 +4,11 @@ __docformat__ = "restructuredtext en"
import sys import sys
import warnings import warnings
from itertools import izip
import numpy import numpy
import theano import theano
from theano.compat import izip
from theano.configparser import config from theano.configparser import config
from theano import gof from theano import gof
from theano.gof import Apply, Constant, Op, Variable from theano.gof import Apply, Constant, Op, Variable
......
from __future__ import print_function from __future__ import print_function
import sys import sys
from copy import copy from copy import copy
from itertools import izip
import numpy import numpy
import theano import theano
from theano import gof from theano import gof
from theano.compat import izip
from theano.compat.six import iteritems from theano.compat.six import iteritems
from theano.gof import Apply, Op, OpenMPOp from theano.gof import Apply, Op, OpenMPOp
from theano import scalar from theano import scalar
......
...@@ -5,12 +5,12 @@ These functions implement special cases of exp and log to improve numerical stab ...@@ -5,12 +5,12 @@ These functions implement special cases of exp and log to improve numerical stab
from __future__ import print_function from __future__ import print_function
import warnings import warnings
from itertools import imap
import numpy import numpy
import theano import theano
from theano import config, gof, printing, scalar from theano import config, gof, printing, scalar
from theano.compat import imap
from theano.configparser import AddConfigVar, BoolParam from theano.configparser import AddConfigVar, BoolParam
from theano.printing import pprint from theano.printing import pprint
from theano.tensor import basic as tensor from theano.tensor import basic as tensor
......
from __future__ import print_function from __future__ import print_function
import unittest import unittest
from itertools import imap
import numpy import numpy
from theano.compat import imap
import theano.tensor.inplace import theano.tensor.inplace
from theano.tensor import basic as tensor from theano.tensor import basic as tensor
from theano import tensor as T from theano import tensor as T
......
...@@ -9,7 +9,6 @@ import logging ...@@ -9,7 +9,6 @@ import logging
_logger = logging.getLogger('theano.tensor.opt') _logger = logging.getLogger('theano.tensor.opt')
import itertools import itertools
from itertools import izip
import operator import operator
import sys import sys
import time import time
...@@ -21,6 +20,7 @@ import numpy as N # guys... please don't do this in the library :( ...@@ -21,6 +20,7 @@ import numpy as N # guys... please don't do this in the library :(
import theano import theano
from theano import gof from theano import gof
from theano.compat import izip
from theano.compat.six import integer_types, iteritems from theano.compat.six import integer_types, iteritems
from theano.compat.six.moves import reduce from theano.compat.six.moves import reduce
from theano.gof import opt, InconsistencyError, TopoOptimizer, graph from theano.gof import opt, InconsistencyError, TopoOptimizer, graph
......
from copy import copy from copy import copy
from itertools import izip
import os import os
import sys import sys
from textwrap import dedent from textwrap import dedent
...@@ -10,6 +9,7 @@ _logger = logging.getLogger("theano.tensor.subtensor") ...@@ -10,6 +9,7 @@ _logger = logging.getLogger("theano.tensor.subtensor")
import numpy import numpy
import theano import theano
from theano.compat import izip
from theano.compat.six import integer_types from theano.compat.six import integer_types
from theano.gradient import DisconnectedType from theano.gradient import DisconnectedType
from theano import gof from theano import gof
......
...@@ -8,8 +8,8 @@ from tempfile import mkstemp ...@@ -8,8 +8,8 @@ from tempfile import mkstemp
import unittest import unittest
import warnings import warnings
from copy import copy, deepcopy from copy import copy, deepcopy
from itertools import izip
# Import builtin min to be able to use it after importing the tensor version. # Import builtin min to be able to use it after importing the tensor version.
from theano.compat import izip
from theano.compat.six.moves.builtins import min as builtin_min from theano.compat.six.moves.builtins import min as builtin_min
from nose.tools import assert_raises from nose.tools import assert_raises
from nose.plugins.skip import SkipTest from nose.plugins.skip import SkipTest
......
import theano.compat.six.moves.cPickle as pickle import theano.compat.six.moves.cPickle as pickle
from copy import copy from copy import copy
from itertools import imap
import unittest import unittest
import numpy import numpy
...@@ -9,6 +8,7 @@ from nose.plugins.attrib import attr ...@@ -9,6 +8,7 @@ from nose.plugins.attrib import attr
from nose.tools import raises from nose.tools import raises
import theano import theano
from theano.compat import imap
from theano import gof, scalar, config from theano import gof, scalar, config
from theano import tensor from theano import tensor
......
from itertools import izip
import logging import logging
import sys import sys
import unittest import unittest
...@@ -8,7 +7,7 @@ from nose.plugins.attrib import attr ...@@ -8,7 +7,7 @@ from nose.plugins.attrib import attr
import numpy import numpy
import theano import theano
from theano.compat import exc_message from theano.compat import exc_message, izip
from theano.compat.six import StringIO from theano.compat.six import StringIO
from theano.compile import DeepCopyOp from theano.compile import DeepCopyOp
from theano import config from theano import config
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论