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