提交 b90a5388 authored 作者: Brandon T. Willard's avatar Brandon T. Willard

Apply isort to theano.tensor top-level modules

上级 96ce7bd7
......@@ -5,66 +5,61 @@ __docformat__ = "restructuredtext en"
import warnings
from theano.tensor.basic import *
from theano.tensor.subtensor import *
from theano.tensor.type_other import *
from theano.tensor.var import (
_tensor_py_operators,
TensorVariable,
TensorConstantSignature,
TensorConstant,
)
from theano.tensor import opt
from theano.tensor import opt_uncanonicalize
from theano.tensor import blas
from theano.tensor import blas_scipy
from theano.tensor import blas_c
from theano.tensor import xlogx
from theano.tensor import nlinalg
# These imports cannot be performed here because the modules depend on tensor. This is done at the
# end of theano.__init__.py instead.
# from theano.tensor import raw_random
# from theano.tensor import shared_randomstreams
from theano.tensor.elemwise import DimShuffle, Elemwise, CAReduce
from theano.tensor import sharedvar # adds shared-variable constructors
# We import as `_shared` instead of `shared` to avoid confusion between
# `theano.shared` and `tensor._shared`.
from theano.tensor.sharedvar import tensor_constructor as _shared
from theano.tensor.io import *
from theano.tensor import nnet # used for softmax, sigmoid, etc.
# SpecifyShape is defined in theano.compile, but should be available in tensor
from theano.compile import SpecifyShape, specify_shape
from theano.gradient import (
Rop,
Lop,
Rop,
consider_constant,
grad,
hessian,
jacobian,
numeric_grad,
verify_grad,
jacobian,
hessian,
consider_constant,
)
from theano.tensor.sort import sort, argsort, topk, argtopk, topk_and_argtopk
from theano.tensor import nnet # used for softmax, sigmoid, etc.
from theano.tensor import sharedvar # adds shared-variable constructors
from theano.tensor import (
blas,
blas_c,
blas_scipy,
nlinalg,
opt,
opt_uncanonicalize,
xlogx,
)
from theano.tensor.basic import *
from theano.tensor.elemwise import CAReduce, DimShuffle, Elemwise
from theano.tensor.extra_ops import (
DiffOp,
bincount,
squeeze,
repeat,
bartlett,
bincount,
cumprod,
cumsum,
fill_diagonal,
fill_diagonal_offset,
cumsum,
cumprod,
unravel_index,
ravel_multi_index,
repeat,
squeeze,
unravel_index,
)
from theano.tensor.io import *
# SpecifyShape is defined in theano.compile, but should be available in tensor
from theano.compile import SpecifyShape, specify_shape
# We import as `_shared` instead of `shared` to avoid confusion between
# `theano.shared` and `tensor._shared`.
from theano.tensor.sharedvar import tensor_constructor as _shared
from theano.tensor.sort import argsort, argtopk, sort, topk, topk_and_argtopk
from theano.tensor.subtensor import *
from theano.tensor.type_other import *
from theano.tensor.var import (
TensorConstant,
TensorConstantSignature,
TensorVariable,
_tensor_py_operators,
)
# These imports cannot be performed here because the modules depend on tensor. This is done at the
# end of theano.__init__.py instead.
# from theano.tensor import raw_random
# from theano.tensor import shared_randomstreams
"""A `Type` and `Op` classes to work with numpy.ndarrays symbolically."""
import warnings
import numbers
import logging
import builtins
import logging
import numbers
import warnings
from collections.abc import Sequence
from functools import partial
import numpy as np
from six import integer_types
import theano
import theano.scalar.sharedvar
from theano import compile, config, gof, printing
from theano import scalar as scal
from functools import partial
from collections.abc import Sequence
from six import integer_types
from theano import config, gof, scalar as scal, compile, printing
from theano.gof import Apply, Constant, Op, Variable, ParamsType
# For history
from theano.compile import Rebroadcast, Shape, shape
from theano.gof import Apply, Constant, Op, ParamsType, Variable
from theano.gof.type import Generic
# We use these exceptions as well.
from theano.gradient import DisconnectedType, grad_not_implemented, grad_undefined
from theano.printing import min_informative_str, pprint
from theano.scalar import int32
from theano.tensor import elemwise
from theano.tensor.var import (
TensorVariable,
TensorConstant,
_tensor_py_operators,
)
# set up the external interface
from theano.tensor.elemwise import CAReduce, DimShuffle, Elemwise, Sum
from theano.tensor.type import TensorType, values_eq_approx_always_true
from theano.tensor.type_other import NoneConst
from theano.printing import pprint, min_informative_str
from theano.tensor.var import TensorConstant, TensorVariable, _tensor_py_operators
# For history
from theano.compile import Rebroadcast, Shape, shape
# We use these exceptions as well.
from theano.gradient import grad_undefined
from theano.gradient import grad_not_implemented
from theano.gradient import DisconnectedType
# set up the external interface
from theano.tensor.elemwise import Elemwise, DimShuffle, CAReduce, Sum
_logger = logging.getLogger("theano.tensor.basic")
......
......@@ -133,40 +133,40 @@ import time
import numpy as np
import numpy.distutils
try:
import numpy.distutils.__config__ # noqa
except ImportError:
pass
import theano.scalar
from functools import reduce
import theano.scalar
from theano import config
from theano.compile.mode import optdb
from theano.gof import (
Apply,
EquilibriumOptimizer,
InconsistencyError,
Op,
view_roots,
local_optimizer,
Optimizer,
InconsistencyError,
SequenceDB,
EquilibriumOptimizer,
Apply,
ReplacementDidntRemovedError,
SequenceDB,
local_optimizer,
view_roots,
)
from theano.gof.toolbox import ReplaceValidate
from theano.gof.utils import TestValueError, MethodNotDefined, memoize
from theano.gof.params_type import ParamsType
from theano.gof.opt import inherit_stack_trace
from theano.printing import pprint, FunctionPrinter, debugprint
from theano.compile.mode import optdb
from theano.gof.params_type import ParamsType
from theano.gof.toolbox import ReplaceValidate
from theano.gof.utils import MethodNotDefined, TestValueError, memoize
from theano.printing import FunctionPrinter, debugprint, pprint
from theano.scalar import bool as bool_t
from theano.tensor import basic as tt
from theano.tensor.blas_headers import blas_header_text
from theano.tensor.blas_headers import blas_header_version
from theano.tensor.blas_headers import blas_header_text, blas_header_version
from theano.tensor.opt import in2out, local_dimshuffle_lift
from theano.tensor.type import values_eq_approx_remove_inf_nan
_logger = logging.getLogger("theano.tensor.blas")
try:
......
......@@ -6,12 +6,21 @@ from theano.scalar import bool as bool_t
# Work-around for Python 3.6 issue that prevents `import theano.tensor as tt`
from theano.tensor import basic as tt
from theano.tensor.blas import (
Gemv,
Ger,
blas_header_text,
blas_header_version,
blas_optdb,
gemv_inplace,
gemv_no_inplace,
ger,
ger_destructive,
ldflags,
local_optimizer,
optdb,
)
from theano.tensor.opt import in2out
from theano.tensor.blas import ldflags, blas_header_text, blas_header_version
from theano.tensor.blas import blas_optdb, optdb, local_optimizer
from theano.tensor.blas import Ger, ger, ger_destructive
from theano.tensor.blas import Gemv, gemv_inplace, gemv_no_inplace
class BaseBLAS(object):
......
......@@ -6,14 +6,15 @@ ourselves into the C code.
"""
import logging
import textwrap
import sys
import os
import sys
import textwrap
from os.path import dirname
from theano import config
from theano.gof.cmodule import GCC_compiler
_logger = logging.getLogger("theano.tensor.blas")
......
......@@ -4,9 +4,15 @@ Implementations of BLAS Ops based on scipy's BLAS bindings.
import numpy as np
from theano.tensor.blas import Ger, ger, ger_destructive, have_fblas
from theano.tensor.blas import blas_optdb, optdb, local_optimizer
from theano.tensor.blas import (
Ger,
blas_optdb,
ger,
ger_destructive,
have_fblas,
local_optimizer,
optdb,
)
from theano.tensor.opt import in2out
......
from copy import copy
import numpy as np
import theano
from six import integer_types
from theano import gof
from theano import change_flags
from theano.gof import Apply, Op, COp, OpenMPOp, ParamsType
from theano import scalar
from theano.scalar import get_scalar_type
from theano.printing import pprint
from theano.gradient import DisconnectedType
import theano
from theano import change_flags, gof, scalar
from theano.gof import Apply, COp, Op, OpenMPOp, ParamsType
from theano.gof.null_type import NullType
from theano.tensor import elemwise_cgen as cgen
from theano.gradient import DisconnectedType
from theano.misc.frozendict import frozendict
from theano.printing import pprint
from theano.scalar import get_scalar_type
from theano.tensor import elemwise_cgen as cgen
config = theano.config
......
from collections.abc import Collection
import numpy as np
import theano
from collections.abc import Collection
from theano.gof import Op, Apply, Generic, ParamsType, EnumList
from theano.tensor import basic, nlinalg
from theano.scalar import int32 as int_t, upcast
from theano.gof import Apply, EnumList, Generic, Op, ParamsType
from theano.gradient import (
DisconnectedType,
disconnected_type,
_float_zeros_like,
disconnected_type,
grad_undefined,
)
from theano.scalar import int32 as int_t
from theano.scalar import upcast
from theano.tensor import basic, nlinalg
class CpuContiguous(theano.Op):
class CpuContiguous(Op):
"""
Check to see if the input is c-contiguous,
if it is, do nothing, else return a contiguous array.
......@@ -76,7 +76,7 @@ class CpuContiguous(theano.Op):
cpu_contiguous = CpuContiguous()
class SearchsortedOp(theano.Op):
class SearchsortedOp(Op):
"""Wrapper of numpy.searchsorted.
For full documentation, see :func:`searchsorted`.
......@@ -263,7 +263,7 @@ def searchsorted(x, v, side="left", sorter=None):
return SearchsortedOp(side=side)(x, v, sorter)
class CumOp(theano.Op):
class CumOp(Op):
# See function cumsum/cumprod for docstring
__props__ = ("axis", "mode")
......@@ -437,7 +437,7 @@ def cumprod(x, axis=None):
# CumsumOp and CumprodOp are for compatibility with old version,
# just in case unpickling a theano function with old Ops.
class CumsumOp(theano.Op):
class CumsumOp(Op):
__props__ = ("axis",)
def __new__(typ, *args, **kwargs):
......@@ -446,7 +446,7 @@ class CumsumOp(theano.Op):
return obj
class CumprodOp(theano.Op):
class CumprodOp(Op):
__props__ = ("axis",)
def __new__(typ, *args, **kwargs):
......@@ -455,7 +455,7 @@ class CumprodOp(theano.Op):
return obj
class DiffOp(theano.Op):
class DiffOp(Op):
# See function diff for docstring
__props__ = ("n", "axis")
......@@ -646,7 +646,7 @@ def compress(condition, x, axis=None):
return x.take(indices, axis=axis)
class RepeatOp(theano.Op):
class RepeatOp(Op):
# See the repeat function for docstring
__props__ = ("axis",)
......@@ -1164,7 +1164,7 @@ def to_one_hot(y, nb_class, dtype=None):
return ret
class Unique(theano.Op):
class Unique(Op):
"""
Wraps numpy.unique. This op is not implemented on the GPU.
......
import numpy as np
import theano.tensor as tt
from theano import gof
from theano.gradient import DisconnectedType
......
import numpy as np
import math
import numpy as np
from theano import gof, tensor
......
from theano import scalar as scal
from . import elemwise
from theano import printing
from theano import scalar as scal
from theano.printing import pprint
from . import elemwise
def _scal_inplace(symbol):
"""Replace a symbol definition with an elementwise version of the corresponding scalar Op"""
......
import numpy as np
import theano
from theano import gof
from theano.gof import Constant, Generic, Op
from theano.gof.sched import key_to_cmp
from theano.tensor import tensor
import theano
##########################
# Disk Access
......
import logging
import warnings
import numpy as np
from functools import partial
import numpy as np
import theano
from theano.tensor import as_tensor_variable
from theano.gof import Op, Apply
from theano.gof import Apply, Op
from theano.gradient import DisconnectedType
from theano.tensor import basic as tensor
from theano.tensor.basic import ExtractDiag
from theano.tensor.basic import ExtractDiag, as_tensor_variable
logger = logging.getLogger(__name__)
......
......@@ -2,122 +2,115 @@
# TODO: intelligent merge for mul/add
# TODO: 0*x -> 0
import logging
import itertools
import logging
import operator
import sys
import time
import traceback
import warnings
from collections import defaultdict
from functools import reduce
import numpy as np
from six import StringIO, integer_types
import theano
import theano.scalar.basic as ts
# import theano.tensor.basic as tt
from functools import reduce
from collections import defaultdict
from six import integer_types, StringIO
from theano import (
gof,
config,
compile,
) # to register the optimizer built by this file
# Work-around for Python 3.6 issue that prevents `import theano.tensor as tt`
from theano.tensor import basic as tt
from theano import compile, config, gof # to register the optimizer built by this file
from theano.compile.ops import Shape, Shape_i
from theano.gof import (
opt,
Constant,
InconsistencyError,
LocalOptimizer,
OpRemove,
PatternSub,
TopoOptimizer,
graph,
Variable,
Constant,
graph,
opt,
toolbox,
PatternSub,
OpRemove,
LocalOptimizer,
)
from theano.gof.op import Op
from theano.gof.opt import (
local_optimizer,
Optimizer,
copy_stack_trace,
in2out,
Optimizer,
local_optimizer,
pre_constant_merge,
pre_greedy_local_optimizer,
)
from theano.gof.utils import MethodNotDefined, TestValueError
from theano.gradient import DisconnectedType
from theano.tensor.elemwise import (
Elemwise,
DimShuffle,
Prod,
CAReduce,
All,
Any,
Sum,
ProdWithoutZeros,
)
from theano.tensor.subtensor import (
get_idx_list,
get_canonical_form_slice,
Subtensor,
IncSubtensor,
as_index_constant,
AdvancedIncSubtensor1,
AdvancedIncSubtensor,
AdvancedSubtensor1,
advanced_subtensor,
advanced_subtensor1,
advanced_inc_subtensor1,
)
from theano.tensor.sort import TopKOp
from theano.compile.ops import Shape, Shape_i
from theano.tensor.type import (
values_eq_approx_remove_inf,
values_eq_approx_remove_nan,
values_eq_approx_remove_inf_nan,
)
# Work-around for Python 3.6 issue that prevents `import theano.tensor as tt`
from theano.tensor import basic as tt
from theano.tensor.basic import (
Join,
Rebroadcast,
Flatten,
Split,
Tile,
Alloc,
AllocEmpty,
alloc,
fill,
get_scalar_constant_value,
ShapeError,
extract_constant,
Dot,
Flatten,
Join,
NotScalarConstantError,
Rebroadcast,
Reshape,
mul,
ScalarFromTensor,
ShapeError,
Split,
TensorFromScalar,
Tile,
abs_,
pow,
true_div,
int_div,
add,
alloc,
erf,
erfc,
extract_constant,
fill,
get_scalar_constant_value,
int_div,
inv,
log,
Dot,
log1p,
mul,
neg,
pow,
sub,
inv,
tensor_copy,
TensorFromScalar,
ScalarFromTensor,
true_div,
)
from theano.tensor.elemwise import (
All,
Any,
CAReduce,
DimShuffle,
Elemwise,
Prod,
ProdWithoutZeros,
Sum,
)
from theano.tensor.sort import TopKOp
from theano.tensor.subtensor import (
AdvancedIncSubtensor,
AdvancedIncSubtensor1,
AdvancedSubtensor1,
IncSubtensor,
Subtensor,
advanced_inc_subtensor1,
advanced_subtensor,
advanced_subtensor1,
as_index_constant,
get_canonical_form_slice,
get_idx_list,
)
from theano.tensor.type import (
values_eq_approx_remove_inf,
values_eq_approx_remove_inf_nan,
values_eq_approx_remove_nan,
)
# import theano.tensor.basic as tt
_logger = logging.getLogger("theano.tensor.opt")
......
......@@ -33,13 +33,13 @@ supposed to be canonical.
import logging
from theano.tensor.elemwise import CAReduce
from theano.tensor import basic as tt
from theano import scalar as scal
from theano.tensor import DimShuffle, Subtensor
from theano.gof.opt import copy_stack_trace, local_optimizer
from theano.tensor import basic as tt
from theano.tensor.elemwise import CAReduce, DimShuffle
from theano.tensor.opt import register_uncanonicalize
from theano.tensor.subtensor import Subtensor
_logger = logging.getLogger("theano.tensor.opt")
......
......@@ -2,20 +2,17 @@
import sys
import numpy as np
import theano
from copy import copy
from functools import reduce
import numpy as np
from six import string_types
from theano import tensor
from theano.tensor import opt
from theano import gof
import theano
from theano import gof, tensor
from theano.compile import optdb
from theano.tensor import opt
__docformat__ = "restructuredtext en"
......
......@@ -9,9 +9,10 @@ import copy
import numpy as np
from theano.compile.sharedvalue import SharedVariable, shared_constructor, shared
from theano.compile.sharedvalue import SharedVariable, shared, shared_constructor
from theano.tensor import raw_random
__docformat__ = "restructuredtext en"
......
......@@ -4,8 +4,8 @@ import numpy as np
from six import integer_types
import theano.tensor.basic
from theano.compile import SharedVariable, shared_constructor
from theano.tensor.basic import TensorType, _tensor_py_operators
from theano.compile import shared_constructor, SharedVariable
def load_shared_variable(val):
......
......@@ -4,13 +4,13 @@ generic 2D convolution.
"""
import logging
import warnings
import theano
import theano.tensor as tensor
from theano.tensor.nnet import conv
import logging
__docformat__ = "restructuredtext en"
......
......@@ -3,15 +3,14 @@ Ops for downsampling images.
Planned:
Pool, DownsampleAvg, DownsampleSoftmax.
"""
import warnings
import itertools
import warnings
import numpy as np
import theano
from theano import gof, OpenMPOp, tensor, Variable, Apply
from theano.gof import ParamsType, EnumList
from theano import Apply, OpenMPOp, Variable, gof, tensor
from theano.gof import EnumList, ParamsType
from theano.gradient import DisconnectedType
from theano.scalar import bool as bool_t
......
import logging
import warnings
import numpy as np
try:
import scipy.linalg
......@@ -12,10 +12,11 @@ except ImportError:
# some ops (e.g. Cholesky, Solve, A_Xinv_b) won't work
imported_scipy = False
from theano import tensor
import theano.tensor
from theano import tensor
from theano.gof import Apply, Op
from theano.tensor import as_tensor_variable
from theano.gof import Op, Apply
logger = logging.getLogger(__name__)
......
import numpy as np
import theano
from theano.tensor.basic import mul, arange
from theano.gof.op import Op
from theano.gradient import grad_undefined
from theano.tensor.basic import arange, mul
from theano.tensor.subtensor import set_subtensor
......@@ -18,7 +20,7 @@ def _check_tensor_is_scalar(var):
raise ValueError(msg % (var, var.ndim))
class SortOp(theano.Op):
class SortOp(Op):
"""
This class is a wrapper for numpy sort function.
......@@ -153,7 +155,7 @@ def sort(a, axis=-1, kind="quicksort", order=None):
return SortOp(kind, order)(a, axis)
class ArgSortOp(theano.Op):
class ArgSortOp(Op):
"""
This class is a wrapper for numpy argsort function.
......@@ -303,7 +305,7 @@ def _topk_py_impl(op, x, k, axis, idx_dtype):
return zi.astype(idx_dtype)
class TopKOp(theano.Op):
class TopKOp(Op):
"""Operations related to finding k-largest elements.
Parameters
......
import logging
import sys
import warnings
import logging
import numpy as np
import theano
from itertools import chain, groupby
from textwrap import dedent
from itertools import groupby, chain
import numpy as np
from six import integer_types
from theano import gof, scalar as scal, config
from theano.gof import Apply, hashtype, Op, Type, MethodNotDefined, ParamsType
import theano
from theano import config, gof
from theano import scalar as scal
from theano.gof import Apply, MethodNotDefined, Op, ParamsType, Type, hashtype
from theano.gradient import DisconnectedType
from theano.printing import pprint
from theano.tensor.basic import (
alloc,
NotScalarConstantError,
TensorType,
addbroadcast,
alloc,
clip,
get_scalar_constant_value,
TensorType,
NotScalarConstantError,
)
from theano.tensor.elemwise import DimShuffle
from theano.tensor.inc_code import inc_code
from theano.tensor.extra_ops import broadcast_shape
from theano.tensor.type_other import NoneConst, SliceType, NoneTypeT, make_slice
from theano.tensor.inc_code import inc_code
from theano.tensor.type_other import NoneConst, NoneTypeT, SliceType, make_slice
_logger = logging.getLogger("theano.tensor.subtensor")
......@@ -107,7 +105,7 @@ def get_canonical_form_slice(theslice, length):
if the resulting set of numbers needs to be reversed or not.
"""
from theano.tensor import switch, lt, ge, sgn
from theano.tensor import ge, lt, sgn, switch
if isinstance(theslice, slice):
......@@ -269,7 +267,7 @@ def range_len(slc):
Adapted from CPython.
"""
from theano.tensor import switch, and_, lt, gt
from theano.tensor import and_, gt, lt, switch
start, stop, step = tuple(
as_index_constant(a) for a in [slc.start, slc.stop, slc.step]
......
......@@ -5,8 +5,9 @@ import numpy as np
import theano
from theano import config
from theano.gof import hashtype, Type, Variable
from theano import scalar as scal
from theano.gof import Type, Variable, hashtype
_logger = logging.getLogger("theano.tensor.type")
......
import numpy as np
import theano
from theano.gof.utils import hash_from_code
......
import copy
import traceback as tb
import warnings
from collections.abc import Iterable
import numpy as np
import theano
from six import integer_types
from collections.abc import Iterable
from theano.scalar import ComplexError, IntegerDivisionError
import theano
from theano import config
from theano.gof import Constant, Variable
from theano.gof.utils import hashtype
from theano.tensor.utils import hash_from_ndarray
from theano.scalar import ComplexError, IntegerDivisionError
from theano.tensor.type import TensorType
from theano import config
from theano.tensor.utils import hash_from_ndarray
class _tensor_py_operators(object):
......
import numpy as np
from theano.tensor.elemwise import Elemwise
from theano import scalar
from theano.tensor.elemwise import Elemwise
class XlogX(scalar.UnaryScalarOp):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论