Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b90a5388
提交
b90a5388
authored
10月 21, 2020
作者:
Brandon T. Willard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Apply isort to theano.tensor top-level modules
上级
96ce7bd7
隐藏空白字符变更
内嵌
并排
正在显示
27 个修改的文件
包含
256 行增加
和
264 行删除
+256
-264
__init__.py
theano/tensor/__init__.py
+44
-49
basic.py
theano/tensor/basic.py
+18
-27
blas.py
theano/tensor/blas.py
+15
-15
blas_c.py
theano/tensor/blas_c.py
+14
-5
blas_headers.py
theano/tensor/blas_headers.py
+3
-2
blas_scipy.py
theano/tensor/blas_scipy.py
+9
-3
elemwise.py
theano/tensor/elemwise.py
+8
-12
extra_ops.py
theano/tensor/extra_ops.py
+15
-15
fft.py
theano/tensor/fft.py
+0
-1
fourier.py
theano/tensor/fourier.py
+3
-1
inplace.py
theano/tensor/inplace.py
+3
-2
io.py
theano/tensor/io.py
+3
-1
nlinalg.py
theano/tensor/nlinalg.py
+5
-5
opt.py
theano/tensor/opt.py
+67
-74
opt_uncanonicalize.py
theano/tensor/opt_uncanonicalize.py
+4
-4
raw_random.py
theano/tensor/raw_random.py
+5
-8
shared_randomstreams.py
theano/tensor/shared_randomstreams.py
+2
-1
sharedvar.py
theano/tensor/sharedvar.py
+1
-1
conv.py
theano/tensor/signal/conv.py
+1
-1
pool.py
theano/tensor/signal/pool.py
+3
-4
slinalg.py
theano/tensor/slinalg.py
+4
-3
sort.py
theano/tensor/sort.py
+6
-4
subtensor.py
theano/tensor/subtensor.py
+15
-17
type.py
theano/tensor/type.py
+2
-1
utils.py
theano/tensor/utils.py
+0
-1
var.py
theano/tensor/var.py
+5
-6
xlogx.py
theano/tensor/xlogx.py
+1
-1
没有找到文件。
theano/tensor/__init__.py
浏览文件 @
b90a5388
...
@@ -5,66 +5,61 @@ __docformat__ = "restructuredtext en"
...
@@ -5,66 +5,61 @@ __docformat__ = "restructuredtext en"
import
warnings
import
warnings
from
theano.tensor.basic
import
*
# SpecifyShape is defined in theano.compile, but should be available in tensor
from
theano.tensor.subtensor
import
*
from
theano.compile
import
SpecifyShape
,
specify_shape
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.
from
theano.gradient
import
(
from
theano.gradient
import
(
Rop
,
Lop
,
Lop
,
Rop
,
consider_constant
,
grad
,
grad
,
hessian
,
jacobian
,
numeric_grad
,
numeric_grad
,
verify_grad
,
verify_grad
,
jacobian
,
hessian
,
consider_constant
,
)
)
from
theano.tensor
import
nnet
# used for softmax, sigmoid, etc.
from
theano.tensor.sort
import
sort
,
argsort
,
topk
,
argtopk
,
topk_and_argtopk
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
(
from
theano.tensor.extra_ops
import
(
DiffOp
,
DiffOp
,
bincount
,
squeeze
,
repeat
,
bartlett
,
bartlett
,
bincount
,
cumprod
,
cumsum
,
fill_diagonal
,
fill_diagonal
,
fill_diagonal_offset
,
fill_diagonal_offset
,
cumsum
,
cumprod
,
unravel_index
,
ravel_multi_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
# We import as `_shared` instead of `shared` to avoid confusion between
from
theano.compile
import
SpecifyShape
,
specify_shape
# `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
theano/tensor/basic.py
浏览文件 @
b90a5388
"""A `Type` and `Op` classes to work with numpy.ndarrays symbolically."""
"""A `Type` and `Op` classes to work with numpy.ndarrays symbolically."""
import
warnings
import
numbers
import
logging
import
builtins
import
builtins
import
logging
import
numbers
import
warnings
from
collections.abc
import
Sequence
from
functools
import
partial
import
numpy
as
np
import
numpy
as
np
from
six
import
integer_types
import
theano
import
theano
import
theano.scalar.sharedvar
import
theano.scalar.sharedvar
from
theano
import
compile
,
config
,
gof
,
printing
from
theano
import
scalar
as
scal
from
functools
import
partial
# For history
from
collections.abc
import
Sequence
from
theano.compile
import
Rebroadcast
,
Shape
,
shape
from
theano.gof
import
Apply
,
Constant
,
Op
,
ParamsType
,
Variable
from
six
import
integer_types
from
theano
import
config
,
gof
,
scalar
as
scal
,
compile
,
printing
from
theano.gof
import
Apply
,
Constant
,
Op
,
Variable
,
ParamsType
from
theano.gof.type
import
Generic
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.scalar
import
int32
from
theano.tensor
import
elemwise
from
theano.tensor
import
elemwise
from
theano.tensor.var
import
(
TensorVariable
,
# set up the external interface
TensorConstant
,
from
theano.tensor.elemwise
import
CAReduce
,
DimShuffle
,
Elemwise
,
Sum
_tensor_py_operators
,
)
from
theano.tensor.type
import
TensorType
,
values_eq_approx_always_true
from
theano.tensor.type
import
TensorType
,
values_eq_approx_always_true
from
theano.tensor.type_other
import
NoneConst
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"
)
_logger
=
logging
.
getLogger
(
"theano.tensor.basic"
)
...
...
theano/tensor/blas.py
浏览文件 @
b90a5388
...
@@ -133,40 +133,40 @@ import time
...
@@ -133,40 +133,40 @@ import time
import
numpy
as
np
import
numpy
as
np
import
numpy.distutils
import
numpy.distutils
try
:
try
:
import
numpy.distutils.__config__
# noqa
import
numpy.distutils.__config__
# noqa
except
ImportError
:
except
ImportError
:
pass
pass
import
theano.scalar
from
functools
import
reduce
from
functools
import
reduce
import
theano.scalar
from
theano
import
config
from
theano
import
config
from
theano.compile.mode
import
optdb
from
theano.gof
import
(
from
theano.gof
import
(
Apply
,
EquilibriumOptimizer
,
InconsistencyError
,
Op
,
Op
,
view_roots
,
local_optimizer
,
Optimizer
,
Optimizer
,
InconsistencyError
,
SequenceDB
,
EquilibriumOptimizer
,
Apply
,
ReplacementDidntRemovedError
,
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.gof.opt
import
inherit_stack_trace
from
theano.printing
import
pprint
,
FunctionPrinter
,
debugprint
from
theano.gof.params_type
import
ParamsType
from
theano.compile.mode
import
optdb
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.scalar
import
bool
as
bool_t
from
theano.tensor
import
basic
as
tt
from
theano.tensor
import
basic
as
tt
from
theano.tensor.blas_headers
import
blas_header_text
from
theano.tensor.blas_headers
import
blas_header_text
,
blas_header_version
from
theano.tensor.blas_headers
import
blas_header_version
from
theano.tensor.opt
import
in2out
,
local_dimshuffle_lift
from
theano.tensor.opt
import
in2out
,
local_dimshuffle_lift
from
theano.tensor.type
import
values_eq_approx_remove_inf_nan
from
theano.tensor.type
import
values_eq_approx_remove_inf_nan
_logger
=
logging
.
getLogger
(
"theano.tensor.blas"
)
_logger
=
logging
.
getLogger
(
"theano.tensor.blas"
)
try
:
try
:
...
...
theano/tensor/blas_c.py
浏览文件 @
b90a5388
...
@@ -6,12 +6,21 @@ from theano.scalar import bool as bool_t
...
@@ -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`
# Work-around for Python 3.6 issue that prevents `import theano.tensor as tt`
from
theano.tensor
import
basic
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.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
):
class
BaseBLAS
(
object
):
...
...
theano/tensor/blas_headers.py
浏览文件 @
b90a5388
...
@@ -6,14 +6,15 @@ ourselves into the C code.
...
@@ -6,14 +6,15 @@ ourselves into the C code.
"""
"""
import
logging
import
logging
import
textwrap
import
sys
import
os
import
os
import
sys
import
textwrap
from
os.path
import
dirname
from
os.path
import
dirname
from
theano
import
config
from
theano
import
config
from
theano.gof.cmodule
import
GCC_compiler
from
theano.gof.cmodule
import
GCC_compiler
_logger
=
logging
.
getLogger
(
"theano.tensor.blas"
)
_logger
=
logging
.
getLogger
(
"theano.tensor.blas"
)
...
...
theano/tensor/blas_scipy.py
浏览文件 @
b90a5388
...
@@ -4,9 +4,15 @@ Implementations of BLAS Ops based on scipy's BLAS bindings.
...
@@ -4,9 +4,15 @@ Implementations of BLAS Ops based on scipy's BLAS bindings.
import
numpy
as
np
import
numpy
as
np
from
theano.tensor.blas
import
Ger
,
ger
,
ger_destructive
,
have_fblas
from
theano.tensor.blas
import
(
from
theano.tensor.blas
import
blas_optdb
,
optdb
,
local_optimizer
Ger
,
blas_optdb
,
ger
,
ger_destructive
,
have_fblas
,
local_optimizer
,
optdb
,
)
from
theano.tensor.opt
import
in2out
from
theano.tensor.opt
import
in2out
...
...
theano/tensor/elemwise.py
浏览文件 @
b90a5388
from
copy
import
copy
from
copy
import
copy
import
numpy
as
np
import
numpy
as
np
import
theano
from
six
import
integer_types
from
six
import
integer_types
from
theano
import
gof
import
theano
from
theano
import
change_flags
,
gof
,
scalar
from
theano
import
change_flags
from
theano.gof
import
Apply
,
COp
,
Op
,
OpenMPOp
,
ParamsType
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
from
theano.gof.null_type
import
NullType
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.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
config
=
theano
.
config
...
...
theano/tensor/extra_ops.py
浏览文件 @
b90a5388
from
collections.abc
import
Collection
import
numpy
as
np
import
numpy
as
np
import
theano
import
theano
from
theano.gof
import
Apply
,
EnumList
,
Generic
,
Op
,
ParamsType
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.gradient
import
(
from
theano.gradient
import
(
DisconnectedType
,
DisconnectedType
,
disconnected_type
,
_float_zeros_like
,
_float_zeros_like
,
disconnected_type
,
grad_undefined
,
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,
Check to see if the input is c-contiguous,
if it is, do nothing, else return a contiguous array.
if it is, do nothing, else return a contiguous array.
...
@@ -76,7 +76,7 @@ class CpuContiguous(theano.Op):
...
@@ -76,7 +76,7 @@ class CpuContiguous(theano.Op):
cpu_contiguous
=
CpuContiguous
()
cpu_contiguous
=
CpuContiguous
()
class
SearchsortedOp
(
theano
.
Op
):
class
SearchsortedOp
(
Op
):
"""Wrapper of numpy.searchsorted.
"""Wrapper of numpy.searchsorted.
For full documentation, see :func:`searchsorted`.
For full documentation, see :func:`searchsorted`.
...
@@ -263,7 +263,7 @@ def searchsorted(x, v, side="left", sorter=None):
...
@@ -263,7 +263,7 @@ def searchsorted(x, v, side="left", sorter=None):
return
SearchsortedOp
(
side
=
side
)(
x
,
v
,
sorter
)
return
SearchsortedOp
(
side
=
side
)(
x
,
v
,
sorter
)
class
CumOp
(
theano
.
Op
):
class
CumOp
(
Op
):
# See function cumsum/cumprod for docstring
# See function cumsum/cumprod for docstring
__props__
=
(
"axis"
,
"mode"
)
__props__
=
(
"axis"
,
"mode"
)
...
@@ -437,7 +437,7 @@ def cumprod(x, axis=None):
...
@@ -437,7 +437,7 @@ def cumprod(x, axis=None):
# CumsumOp and CumprodOp are for compatibility with old version,
# CumsumOp and CumprodOp are for compatibility with old version,
# just in case unpickling a theano function with old Ops.
# just in case unpickling a theano function with old Ops.
class
CumsumOp
(
theano
.
Op
):
class
CumsumOp
(
Op
):
__props__
=
(
"axis"
,)
__props__
=
(
"axis"
,)
def
__new__
(
typ
,
*
args
,
**
kwargs
):
def
__new__
(
typ
,
*
args
,
**
kwargs
):
...
@@ -446,7 +446,7 @@ class CumsumOp(theano.Op):
...
@@ -446,7 +446,7 @@ class CumsumOp(theano.Op):
return
obj
return
obj
class
CumprodOp
(
theano
.
Op
):
class
CumprodOp
(
Op
):
__props__
=
(
"axis"
,)
__props__
=
(
"axis"
,)
def
__new__
(
typ
,
*
args
,
**
kwargs
):
def
__new__
(
typ
,
*
args
,
**
kwargs
):
...
@@ -455,7 +455,7 @@ class CumprodOp(theano.Op):
...
@@ -455,7 +455,7 @@ class CumprodOp(theano.Op):
return
obj
return
obj
class
DiffOp
(
theano
.
Op
):
class
DiffOp
(
Op
):
# See function diff for docstring
# See function diff for docstring
__props__
=
(
"n"
,
"axis"
)
__props__
=
(
"n"
,
"axis"
)
...
@@ -646,7 +646,7 @@ def compress(condition, x, axis=None):
...
@@ -646,7 +646,7 @@ def compress(condition, x, axis=None):
return
x
.
take
(
indices
,
axis
=
axis
)
return
x
.
take
(
indices
,
axis
=
axis
)
class
RepeatOp
(
theano
.
Op
):
class
RepeatOp
(
Op
):
# See the repeat function for docstring
# See the repeat function for docstring
__props__
=
(
"axis"
,)
__props__
=
(
"axis"
,)
...
@@ -1164,7 +1164,7 @@ def to_one_hot(y, nb_class, dtype=None):
...
@@ -1164,7 +1164,7 @@ def to_one_hot(y, nb_class, dtype=None):
return
ret
return
ret
class
Unique
(
theano
.
Op
):
class
Unique
(
Op
):
"""
"""
Wraps numpy.unique. This op is not implemented on the GPU.
Wraps numpy.unique. This op is not implemented on the GPU.
...
...
theano/tensor/fft.py
浏览文件 @
b90a5388
import
numpy
as
np
import
numpy
as
np
import
theano.tensor
as
tt
import
theano.tensor
as
tt
from
theano
import
gof
from
theano
import
gof
from
theano.gradient
import
DisconnectedType
from
theano.gradient
import
DisconnectedType
...
...
theano/tensor/fourier.py
浏览文件 @
b90a5388
import
numpy
as
np
import
math
import
math
import
numpy
as
np
from
theano
import
gof
,
tensor
from
theano
import
gof
,
tensor
...
...
theano/tensor/inplace.py
浏览文件 @
b90a5388
from
theano
import
scalar
as
scal
from
.
import
elemwise
from
theano
import
printing
from
theano
import
printing
from
theano
import
scalar
as
scal
from
theano.printing
import
pprint
from
theano.printing
import
pprint
from
.
import
elemwise
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"""
...
...
theano/tensor/io.py
浏览文件 @
b90a5388
import
numpy
as
np
import
numpy
as
np
import
theano
from
theano
import
gof
from
theano
import
gof
from
theano.gof
import
Constant
,
Generic
,
Op
from
theano.gof
import
Constant
,
Generic
,
Op
from
theano.gof.sched
import
key_to_cmp
from
theano.gof.sched
import
key_to_cmp
from
theano.tensor
import
tensor
from
theano.tensor
import
tensor
import
theano
##########################
##########################
# Disk Access
# Disk Access
...
...
theano/tensor/nlinalg.py
浏览文件 @
b90a5388
import
logging
import
logging
import
warnings
import
warnings
import
numpy
as
np
from
functools
import
partial
from
functools
import
partial
import
numpy
as
np
import
theano
import
theano
from
theano.tensor
import
as_tensor_variable
from
theano.gof
import
Apply
,
Op
from
theano.gof
import
Op
,
Apply
from
theano.gradient
import
DisconnectedType
from
theano.gradient
import
DisconnectedType
from
theano.tensor
import
basic
as
tensor
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__
)
logger
=
logging
.
getLogger
(
__name__
)
...
...
theano/tensor/opt.py
浏览文件 @
b90a5388
...
@@ -2,122 +2,115 @@
...
@@ -2,122 +2,115 @@
# TODO: intelligent merge for mul/add
# TODO: intelligent merge for mul/add
# TODO: 0*x -> 0
# TODO: 0*x -> 0
import
logging
import
itertools
import
itertools
import
logging
import
operator
import
operator
import
sys
import
sys
import
time
import
time
import
traceback
import
traceback
import
warnings
import
warnings
from
collections
import
defaultdict
from
functools
import
reduce
import
numpy
as
np
import
numpy
as
np
from
six
import
StringIO
,
integer_types
import
theano
import
theano
import
theano.scalar.basic
as
ts
import
theano.scalar.basic
as
ts
from
theano
import
compile
,
config
,
gof
# to register the optimizer built by this file
# import theano.tensor.basic as tt
from
theano.compile.ops
import
Shape
,
Shape_i
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.gof
import
(
from
theano.gof
import
(
op
t
,
Constan
t
,
InconsistencyError
,
InconsistencyError
,
LocalOptimizer
,
OpRemove
,
PatternSub
,
TopoOptimizer
,
TopoOptimizer
,
graph
,
Variable
,
Variable
,
Constant
,
graph
,
opt
,
toolbox
,
toolbox
,
PatternSub
,
OpRemove
,
LocalOptimizer
,
)
)
from
theano.gof.op
import
Op
from
theano.gof.op
import
Op
from
theano.gof.opt
import
(
from
theano.gof.opt
import
(
local_o
ptimizer
,
O
ptimizer
,
copy_stack_trace
,
copy_stack_trace
,
in2out
,
in2out
,
O
ptimizer
,
local_o
ptimizer
,
pre_constant_merge
,
pre_constant_merge
,
pre_greedy_local_optimizer
,
pre_greedy_local_optimizer
,
)
)
from
theano.gof.utils
import
MethodNotDefined
,
TestValueError
from
theano.gof.utils
import
MethodNotDefined
,
TestValueError
from
theano.gradient
import
DisconnectedType
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
(
from
theano.tensor.basic
import
(
Join
,
Rebroadcast
,
Flatten
,
Split
,
Tile
,
Alloc
,
Alloc
,
AllocEmpty
,
AllocEmpty
,
alloc
,
Dot
,
fill
,
Flatten
,
get_scalar_constant_value
,
Join
,
ShapeError
,
extract_constant
,
NotScalarConstantError
,
NotScalarConstantError
,
Rebroadcast
,
Reshape
,
Reshape
,
mul
,
ScalarFromTensor
,
ShapeError
,
Split
,
TensorFromScalar
,
Tile
,
abs_
,
abs_
,
pow
,
true_div
,
int_div
,
add
,
add
,
alloc
,
erf
,
erf
,
erfc
,
erfc
,
extract_constant
,
fill
,
get_scalar_constant_value
,
int_div
,
inv
,
log
,
log
,
Dot
,
log1p
,
log1p
,
mul
,
neg
,
neg
,
pow
,
sub
,
sub
,
inv
,
tensor_copy
,
tensor_copy
,
TensorFromScalar
,
true_div
,
ScalarFromTensor
,
)
)
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"
)
_logger
=
logging
.
getLogger
(
"theano.tensor.opt"
)
...
...
theano/tensor/opt_uncanonicalize.py
浏览文件 @
b90a5388
...
@@ -33,13 +33,13 @@ supposed to be canonical.
...
@@ -33,13 +33,13 @@ supposed to be canonical.
import
logging
import
logging
from
theano.tensor.elemwise
import
CAReduce
from
theano.tensor
import
basic
as
tt
from
theano
import
scalar
as
scal
from
theano
import
scalar
as
scal
from
theano.tensor
import
DimShuffle
,
Subtensor
from
theano.gof.opt
import
copy_stack_trace
,
local_optimizer
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.opt
import
register_uncanonicalize
from
theano.tensor.subtensor
import
Subtensor
_logger
=
logging
.
getLogger
(
"theano.tensor.opt"
)
_logger
=
logging
.
getLogger
(
"theano.tensor.opt"
)
...
...
theano/tensor/raw_random.py
浏览文件 @
b90a5388
...
@@ -2,20 +2,17 @@
...
@@ -2,20 +2,17 @@
import
sys
import
sys
import
numpy
as
np
import
theano
from
copy
import
copy
from
copy
import
copy
from
functools
import
reduce
from
functools
import
reduce
import
numpy
as
np
from
six
import
string_types
from
six
import
string_types
from
theano
import
tensor
import
theano
from
theano.tensor
import
opt
from
theano
import
gof
,
tensor
from
theano
import
gof
from
theano.compile
import
optdb
from
theano.compile
import
optdb
from
theano.tensor
import
opt
__docformat__
=
"restructuredtext en"
__docformat__
=
"restructuredtext en"
...
...
theano/tensor/shared_randomstreams.py
浏览文件 @
b90a5388
...
@@ -9,9 +9,10 @@ import copy
...
@@ -9,9 +9,10 @@ import copy
import
numpy
as
np
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
from
theano.tensor
import
raw_random
__docformat__
=
"restructuredtext en"
__docformat__
=
"restructuredtext en"
...
...
theano/tensor/sharedvar.py
浏览文件 @
b90a5388
...
@@ -4,8 +4,8 @@ import numpy as np
...
@@ -4,8 +4,8 @@ import numpy as np
from
six
import
integer_types
from
six
import
integer_types
import
theano.tensor.basic
import
theano.tensor.basic
from
theano.compile
import
SharedVariable
,
shared_constructor
from
theano.tensor.basic
import
TensorType
,
_tensor_py_operators
from
theano.tensor.basic
import
TensorType
,
_tensor_py_operators
from
theano.compile
import
shared_constructor
,
SharedVariable
def
load_shared_variable
(
val
):
def
load_shared_variable
(
val
):
...
...
theano/tensor/signal/conv.py
浏览文件 @
b90a5388
...
@@ -4,13 +4,13 @@ generic 2D convolution.
...
@@ -4,13 +4,13 @@ generic 2D convolution.
"""
"""
import
logging
import
warnings
import
warnings
import
theano
import
theano
import
theano.tensor
as
tensor
import
theano.tensor
as
tensor
from
theano.tensor.nnet
import
conv
from
theano.tensor.nnet
import
conv
import
logging
__docformat__
=
"restructuredtext en"
__docformat__
=
"restructuredtext en"
...
...
theano/tensor/signal/pool.py
浏览文件 @
b90a5388
...
@@ -3,15 +3,14 @@ Ops for downsampling images.
...
@@ -3,15 +3,14 @@ Ops for downsampling images.
Planned:
Planned:
Pool, DownsampleAvg, DownsampleSoftmax.
Pool, DownsampleAvg, DownsampleSoftmax.
"""
"""
import
warnings
import
itertools
import
itertools
import
warnings
import
numpy
as
np
import
numpy
as
np
import
theano
import
theano
from
theano
import
Apply
,
OpenMPOp
,
Variable
,
gof
,
tensor
from
theano
import
gof
,
OpenMPOp
,
tensor
,
Variable
,
Apply
from
theano.gof
import
EnumList
,
ParamsType
from
theano.gof
import
ParamsType
,
EnumList
from
theano.gradient
import
DisconnectedType
from
theano.gradient
import
DisconnectedType
from
theano.scalar
import
bool
as
bool_t
from
theano.scalar
import
bool
as
bool_t
...
...
theano/tensor/slinalg.py
浏览文件 @
b90a5388
import
logging
import
logging
import
warnings
import
warnings
import
numpy
as
np
import
numpy
as
np
try
:
try
:
import
scipy.linalg
import
scipy.linalg
...
@@ -12,10 +12,11 @@ except ImportError:
...
@@ -12,10 +12,11 @@ except ImportError:
# some ops (e.g. Cholesky, Solve, A_Xinv_b) won't work
# some ops (e.g. Cholesky, Solve, A_Xinv_b) won't work
imported_scipy
=
False
imported_scipy
=
False
from
theano
import
tensor
import
theano.tensor
import
theano.tensor
from
theano
import
tensor
from
theano.gof
import
Apply
,
Op
from
theano.tensor
import
as_tensor_variable
from
theano.tensor
import
as_tensor_variable
from
theano.gof
import
Op
,
Apply
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
...
theano/tensor/sort.py
浏览文件 @
b90a5388
import
numpy
as
np
import
numpy
as
np
import
theano
import
theano
from
theano.
tensor.basic
import
mul
,
arange
from
theano.
gof.op
import
Op
from
theano.gradient
import
grad_undefined
from
theano.gradient
import
grad_undefined
from
theano.tensor.basic
import
arange
,
mul
from
theano.tensor.subtensor
import
set_subtensor
from
theano.tensor.subtensor
import
set_subtensor
...
@@ -18,7 +20,7 @@ def _check_tensor_is_scalar(var):
...
@@ -18,7 +20,7 @@ def _check_tensor_is_scalar(var):
raise
ValueError
(
msg
%
(
var
,
var
.
ndim
))
raise
ValueError
(
msg
%
(
var
,
var
.
ndim
))
class
SortOp
(
theano
.
Op
):
class
SortOp
(
Op
):
"""
"""
This class is a wrapper for numpy sort function.
This class is a wrapper for numpy sort function.
...
@@ -153,7 +155,7 @@ def sort(a, axis=-1, kind="quicksort", order=None):
...
@@ -153,7 +155,7 @@ def sort(a, axis=-1, kind="quicksort", order=None):
return
SortOp
(
kind
,
order
)(
a
,
axis
)
return
SortOp
(
kind
,
order
)(
a
,
axis
)
class
ArgSortOp
(
theano
.
Op
):
class
ArgSortOp
(
Op
):
"""
"""
This class is a wrapper for numpy argsort function.
This class is a wrapper for numpy argsort function.
...
@@ -303,7 +305,7 @@ def _topk_py_impl(op, x, k, axis, idx_dtype):
...
@@ -303,7 +305,7 @@ def _topk_py_impl(op, x, k, axis, idx_dtype):
return
zi
.
astype
(
idx_dtype
)
return
zi
.
astype
(
idx_dtype
)
class
TopKOp
(
theano
.
Op
):
class
TopKOp
(
Op
):
"""Operations related to finding k-largest elements.
"""Operations related to finding k-largest elements.
Parameters
Parameters
...
...
theano/tensor/subtensor.py
浏览文件 @
b90a5388
import
logging
import
sys
import
sys
import
warnings
import
warnings
import
logging
from
itertools
import
chain
,
groupby
import
numpy
as
np
import
theano
from
textwrap
import
dedent
from
textwrap
import
dedent
from
itertools
import
groupby
,
chain
import
numpy
as
np
from
six
import
integer_types
from
six
import
integer_types
from
theano
import
gof
,
scalar
as
scal
,
config
import
theano
from
theano.gof
import
Apply
,
hashtype
,
Op
,
Type
,
MethodNotDefined
,
ParamsType
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.gradient
import
DisconnectedType
from
theano.printing
import
pprint
from
theano.printing
import
pprint
from
theano.tensor.basic
import
(
from
theano.tensor.basic
import
(
alloc
,
NotScalarConstantError
,
TensorType
,
addbroadcast
,
addbroadcast
,
alloc
,
clip
,
clip
,
get_scalar_constant_value
,
get_scalar_constant_value
,
TensorType
,
NotScalarConstantError
,
)
)
from
theano.tensor.elemwise
import
DimShuffle
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.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"
)
_logger
=
logging
.
getLogger
(
"theano.tensor.subtensor"
)
...
@@ -107,7 +105,7 @@ def get_canonical_form_slice(theslice, length):
...
@@ -107,7 +105,7 @@ def get_canonical_form_slice(theslice, length):
if the resulting set of numbers needs to be reversed or not.
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
):
if
isinstance
(
theslice
,
slice
):
...
@@ -269,7 +267,7 @@ def range_len(slc):
...
@@ -269,7 +267,7 @@ def range_len(slc):
Adapted from CPython.
Adapted from CPython.
"""
"""
from
theano.tensor
import
switch
,
and_
,
lt
,
gt
from
theano.tensor
import
and_
,
gt
,
lt
,
switch
start
,
stop
,
step
=
tuple
(
start
,
stop
,
step
=
tuple
(
as_index_constant
(
a
)
for
a
in
[
slc
.
start
,
slc
.
stop
,
slc
.
step
]
as_index_constant
(
a
)
for
a
in
[
slc
.
start
,
slc
.
stop
,
slc
.
step
]
...
...
theano/tensor/type.py
浏览文件 @
b90a5388
...
@@ -5,8 +5,9 @@ import numpy as np
...
@@ -5,8 +5,9 @@ import numpy as np
import
theano
import
theano
from
theano
import
config
from
theano
import
config
from
theano.gof
import
hashtype
,
Type
,
Variable
from
theano
import
scalar
as
scal
from
theano
import
scalar
as
scal
from
theano.gof
import
Type
,
Variable
,
hashtype
_logger
=
logging
.
getLogger
(
"theano.tensor.type"
)
_logger
=
logging
.
getLogger
(
"theano.tensor.type"
)
...
...
theano/tensor/utils.py
浏览文件 @
b90a5388
import
numpy
as
np
import
numpy
as
np
import
theano
import
theano
from
theano.gof.utils
import
hash_from_code
from
theano.gof.utils
import
hash_from_code
...
...
theano/tensor/var.py
浏览文件 @
b90a5388
import
copy
import
copy
import
traceback
as
tb
import
traceback
as
tb
import
warnings
import
warnings
from
collections.abc
import
Iterable
import
numpy
as
np
import
numpy
as
np
import
theano
from
six
import
integer_types
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
import
Constant
,
Variable
from
theano.gof.utils
import
hashtype
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.tensor.type
import
TensorType
from
theano
import
config
from
theano
.tensor.utils
import
hash_from_ndarray
class
_tensor_py_operators
(
object
):
class
_tensor_py_operators
(
object
):
...
...
theano/tensor/xlogx.py
浏览文件 @
b90a5388
import
numpy
as
np
import
numpy
as
np
from
theano.tensor.elemwise
import
Elemwise
from
theano
import
scalar
from
theano
import
scalar
from
theano.tensor.elemwise
import
Elemwise
class
XlogX
(
scalar
.
UnaryScalarOp
):
class
XlogX
(
scalar
.
UnaryScalarOp
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论