Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
62fa59c9
提交
62fa59c9
authored
10月 21, 2020
作者:
Brandon T. Willard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Apply isort to theano.tensor.nnet sub-package modules
上级
b90a5388
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
103 行增加
和
105 行删除
+103
-105
__init__.py
theano/tensor/nnet/__init__.py
+14
-17
abstract_conv.py
theano/tensor/nnet/abstract_conv.py
+15
-9
blocksparse.py
theano/tensor/nnet/blocksparse.py
+3
-2
bn.py
theano/tensor/nnet/bn.py
+5
-7
conv.py
theano/tensor/nnet/conv.py
+8
-8
conv3d2d.py
theano/tensor/nnet/conv3d2d.py
+3
-3
corr.py
theano/tensor/nnet/corr.py
+10
-7
corr3d.py
theano/tensor/nnet/corr3d.py
+9
-6
ctc.py
theano/tensor/nnet/ctc.py
+0
-1
neighbours.py
theano/tensor/nnet/neighbours.py
+0
-1
nnet.py
theano/tensor/nnet/nnet.py
+10
-16
opt.py
theano/tensor/nnet/opt.py
+20
-25
sigm.py
theano/tensor/nnet/sigm.py
+6
-3
没有找到文件。
theano/tensor/nnet/__init__.py
浏览文件 @
62fa59c9
import
warnings
from
.
import
opt
from
.abstract_conv
import
conv2d
as
abstract_conv2d
from
.abstract_conv
import
conv2d_grad_wrt_inputs
,
conv3d
,
separable_conv2d
from
.bn
import
batch_normalization
from
.conv
import
ConvOp
from
.nnet
import
(
CrossentropyCategorical1Hot
,
CrossentropyCategorical1HotGrad
,
...
...
@@ -10,8 +17,8 @@ from .nnet import (
SoftmaxGrad
,
SoftmaxWithBias
,
binary_crossentropy
,
sigmoid_binary_crossentropy
,
categorical_crossentropy
,
confusion_matrix
,
crossentropy_categorical_1hot
,
crossentropy_categorical_1hot_grad
,
crossentropy_softmax_1hot
,
...
...
@@ -22,6 +29,7 @@ from .nnet import (
crossentropy_softmax_max_and_argmax_1hot_with_bias
,
crossentropy_to_crossentropy_with_softmax
,
crossentropy_to_crossentropy_with_softmax_with_bias
,
elu
,
graph_merge_softmax_with_crossentropy_softmax
,
h_softmax
,
logsoftmax
,
...
...
@@ -30,35 +38,24 @@ from .nnet import (
prepend_1_to_each_row
,
prepend_scalar_to_each_row
,
relu
,
selu
,
sigmoid_binary_crossentropy
,
softmax
,
softmax_grad
,
softmax_graph
,
softmax_op
,
softmax_simplifier
,
softmax_with_bias
,
elu
,
selu
,
confusion_matrix
,
softsign
,
)
from
.
import
opt
from
.conv
import
ConvOp
from
.sigm
import
(
softplus
,
hard_sigmoid
,
scalar_sigmoid
,
sigmoid
,
sigmoid_inplace
,
s
calar_sigmoid
,
s
oftplus
,
ultra_fast_sigmoid
,
hard_sigmoid
,
)
from
.bn
import
batch_normalization
import
warnings
from
.abstract_conv
import
conv2d
as
abstract_conv2d
from
.abstract_conv
import
conv2d_grad_wrt_inputs
from
.abstract_conv
import
conv3d
from
.abstract_conv
import
separable_conv2d
def
conv2d
(
...
...
theano/tensor/nnet/abstract_conv.py
浏览文件 @
62fa59c9
...
...
@@ -4,27 +4,33 @@ Abstract conv interface
import
logging
from
six
import
reraise
,
integer_types
import
sys
from
six
import
integer_types
,
reraise
try
:
from
math
import
gcd
except
ImportError
:
from
fractions
import
gcd
import
theano
import
warnings
from
theano.tensor
import
as_tensor_variable
,
patternbroadcast
from
theano.tensor
import
get_scalar_constant_value
,
NotScalarConstantError
from
theano.tensor.opt
import
Assert
from
theano.gof
import
Apply
,
Op
import
numpy
as
np
import
theano
from
theano.gof
import
Apply
,
Op
from
theano.tensor.basic
import
(
NotScalarConstantError
,
as_tensor_variable
,
get_scalar_constant_value
,
patternbroadcast
,
)
from
theano.tensor.opt
import
Assert
import
warnings
import
numpy
as
np
try
:
from
scipy.signal.signaltools
import
_
valfrommode
,
_bvalfromboundary
,
convolve
from
scipy.signal.signaltools
import
_
bvalfromboundary
,
_valfrommode
,
convolve
from
scipy.signal.sigtools
import
_convolve2d
imported_scipy_signal
=
True
...
...
theano/tensor/nnet/blocksparse.py
浏览文件 @
62fa59c9
import
numpy
as
np
import
theano
from
theano
import
Op
,
Apply
from
theano.
tensor
import
discrete_dtypes
from
theano
.gof.graph
import
Apply
from
theano.
gof.op
import
Op
from
theano.gradient
import
grad_undefined
from
theano.tensor.basic
import
discrete_dtypes
class
SparseBlockGemv
(
Op
):
...
...
theano/tensor/nnet/bn.py
浏览文件 @
62fa59c9
import
numpy
as
np
import
theano
# import theano.tensor.basic as tt
from
theano
import
Apply
,
Op
from
theano.gof
import
local_optimizer
from
theano.gof.opt
import
copy_stack_trace
from
theano.gof.graph
import
Apply
from
theano.gof.op
import
Op
from
theano.gof.opt
import
copy_stack_trace
,
local_optimizer
from
theano.scalar
import
Composite
,
add
,
as_common_dtype
,
mul
,
sub
,
true_div
# 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
TensorType
,
as_tensor_variable
from
theano.tensor
.basic
import
as_tensor_variable
from
theano.tensor.elemwise
import
Elemwise
from
theano.tensor.opt
import
register_specialize_device
from
theano.tensor.type
import
TensorType
class
BNComposite
(
Composite
):
...
...
theano/tensor/nnet/conv.py
浏览文件 @
62fa59c9
...
...
@@ -10,27 +10,27 @@ See especially conv2d().
import
logging
import
warnings
import
numpy
as
np
import
warnings
import
theano
from
theano
import
OpenMPOp
from
theano.tensor
import
(
from
theano.gof.graph
import
Apply
from
theano.gof.op
import
OpenMPOp
from
theano.tensor
import
blas
from
theano.tensor.basic
import
(
NotScalarConstantError
,
as_tensor_variable
,
blas
,
get_scalar_constant_value
,
patternbroadcast
,
NotScalarConstantError
,
)
from
theano.gof
import
Apply
from
theano.tensor.nnet.abstract_conv
import
get_conv_output_shape
,
get_conv_shape_1axis
try
:
# TODO: move these back out to global scope when they no longer
# cause an atexit error
from
scipy.signal.signaltools
import
_
valfrommode
,
_bvalfromboundary
from
scipy.signal.signaltools
import
_
bvalfromboundary
,
_valfrommode
from
scipy.signal.sigtools
import
_convolve2d
imported_scipy_signal
=
True
...
...
theano/tensor/nnet/conv3d2d.py
浏览文件 @
62fa59c9
import
theano
from
theano.gradient
import
DisconnectedType
from
theano.gof
import
Op
,
Apply
,
TopoOptimizer
from
theano.gof.opt
import
copy_stack_trace
from
theano
import
tensor
from
theano.gof
import
Apply
,
Op
,
TopoOptimizer
from
theano.gof.opt
import
copy_stack_trace
from
theano.gradient
import
DisconnectedType
def
get_diagonal_subtensor_view
(
x
,
i0
,
i1
):
...
...
theano/tensor/nnet/corr.py
浏览文件 @
62fa59c9
import
os
import
logging
import
os
from
six
import
integer_types
import
theano
from
theano
import
Apply
from
theano
import
gof
from
theano.gof
import
ParamsType
,
EnumList
from
theano.
scalar
import
int64
,
int8
from
theano.
tensor
import
as_tensor_variable
,
TensorType
from
theano.
tensor.nnet.abstract_conv
import
get_conv_output_shape
from
theano.gof
.graph
import
Apply
from
theano.
gof.params_type
import
ParamsType
from
theano.
gof.type
import
EnumList
from
theano.
scalar
import
int8
,
int64
from
theano.tensor
import
blas_headers
from
theano.tensor.blas
import
ldflags
,
blas_header_version
from
theano.tensor.basic
import
as_tensor_variable
from
theano.tensor.blas
import
blas_header_version
,
ldflags
from
theano.tensor.nnet.abstract_conv
import
get_conv_output_shape
from
theano.tensor.type
import
TensorType
_logger
=
logging
.
getLogger
(
__name__
)
...
...
theano/tensor/nnet/corr3d.py
浏览文件 @
62fa59c9
import
os
import
logging
import
os
from
six
import
integer_types
import
theano
from
theano
import
Apply
from
theano
import
gof
from
theano.gof
import
ParamsType
,
EnumList
from
theano.gof.graph
import
Apply
from
theano.gof.params_type
import
ParamsType
from
theano.gof.type
import
EnumList
from
theano.scalar
import
int64
from
theano.tensor
import
as_tensor_variable
,
TensorType
from
theano.tensor.nnet.abstract_conv
import
get_conv_output_shape
from
theano.tensor
import
blas_headers
from
theano.tensor.blas
import
ldflags
,
blas_header_version
from
theano.tensor.basic
import
as_tensor_variable
from
theano.tensor.blas
import
blas_header_version
,
ldflags
from
theano.tensor.nnet.abstract_conv
import
get_conv_output_shape
from
theano.tensor.type
import
TensorType
_logger
=
logging
.
getLogger
(
__name__
)
...
...
theano/tensor/nnet/ctc.py
浏览文件 @
62fa59c9
...
...
@@ -2,7 +2,6 @@ import os
import
sys
import
theano.tensor
as
tt
from
theano
import
config
,
gof
from
theano.gof
import
local_optimizer
from
theano.gof.cmodule
import
GCC_compiler
...
...
theano/tensor/nnet/neighbours.py
浏览文件 @
62fa59c9
...
...
@@ -6,7 +6,6 @@ import numpy as np
import
theano
import
theano.tensor
as
tt
from
theano
import
Apply
,
Op
from
theano.gof
import
EnumList
from
theano.gradient
import
grad_not_implemented
,
grad_undefined
...
...
theano/tensor/nnet/nnet.py
浏览文件 @
62fa59c9
...
...
@@ -17,35 +17,29 @@ import logging
import
warnings
import
numpy
as
np
import
theano
# import theano.tensor.basic as tt
import
theano
from
theano
import
scalar
from
theano.compile
import
optdb
from
theano.gof.graph
import
Apply
from
theano.gof.op
import
Op
from
theano.gof.opt
import
copy_stack_trace
,
local_optimizer
,
optimizer
from
theano.gradient
import
DisconnectedType
,
grad_not_implemented
from
theano.scalar
import
UnaryScalarOp
# 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
extra_ops
,
opt
,
subtensor
from
theano.tensor.basic
import
MaxAndArgmax
,
as_tensor_variable
,
log
from
theano.tensor.elemwise
import
Elemwise
from
theano.tensor.nnet.blocksparse
import
sparse_block_dot
from
theano.tensor.nnet.sigm
import
sigmoid
,
softplus
from
theano.tensor.opt
import
(
register_canonicalize
,
register_specialize
,
register_stabilize
,
register_canonicalize
,
)
from
theano.gof.opt
import
(
optimizer
,
copy_stack_trace
,
local_optimizer
,
)
from
theano.gradient
import
DisconnectedType
,
grad_not_implemented
from
theano.scalar
import
UnaryScalarOp
from
theano.tensor
import
as_tensor_variable
,
extra_ops
,
opt
,
subtensor
from
theano.tensor.elemwise
import
Elemwise
from
theano.tensor.subtensor
import
AdvancedSubtensor
from
theano.tensor.basic
import
log
,
MaxAndArgmax
from
theano.tensor.nnet.blocksparse
import
sparse_block_dot
from
theano.tensor.nnet.sigm
import
sigmoid
,
softplus
from
theano.tensor.type
import
values_eq_approx_remove_inf
,
values_eq_approx_remove_nan
...
...
theano/tensor/nnet/opt.py
浏览文件 @
62fa59c9
...
...
@@ -5,38 +5,33 @@ Optimizations addressing the ops in nnet root directory
import
theano
from
theano
import
compile
,
gof
from
theano.compile
import
optdb
from
theano.gof
import
local_optimizer
from
theano.gof.opt
import
copy_stack_trace
from
theano.tensor.nnet.corr
import
CorrMM
,
CorrMM_gradInputs
,
CorrMM_gradWeights
from
theano.tensor.nnet.corr3d
import
(
Corr3dMM
,
Corr3dMMGradInputs
,
Corr3dMMGradWeights
,
)
from
theano.tensor.nnet.blocksparse
import
(
SparseBlockGemv
,
SparseBlockOuter
,
sparse_block_gemv_inplace
,
sparse_block_outer_inplace
,
from
theano.gof.opt
import
(
LocalMetaOptimizerSkipAssertionError
,
copy_stack_trace
,
local_optimizer
,
)
from
theano.tensor.nnet.abstract_conv
import
(
AbstractConv2d
,
AbstractConv2d_gradWeights
,
AbstractConv2d_gradInputs
,
)
from
theano.tensor.nnet.abstract_conv
import
(
AbstractConv2d_gradWeights
,
AbstractConv3d
,
AbstractConv3d_gradWeights
,
AbstractConv3d_gradInputs
,
AbstractConv3d_gradWeights
,
get_conv_output_shape
,
)
from
theano.tensor.nnet.blocksparse
import
(
SparseBlockGemv
,
SparseBlockOuter
,
sparse_block_gemv_inplace
,
sparse_block_outer_inplace
,
)
from
theano.tensor.nnet.abstract_conv
import
get_conv_output_shape
from
theano.tensor.opt
import
register_specialize_device
from
theano.tensor
import
TensorType
from
theano.tensor
import
opt
# Cpu implementation
from
theano.tensor.nnet.conv
import
conv2d
,
ConvOp
from
theano.tensor.nnet.conv
import
ConvOp
,
conv2d
from
theano.tensor.nnet.corr
import
CorrMM
,
CorrMM_gradInputs
,
CorrMM_gradWeights
from
theano.tensor.nnet.corr3d
import
Corr3dMM
,
Corr3dMMGradInputs
,
Corr3dMMGradWeights
from
theano.tensor.opt
import
in2out
,
register_specialize_device
from
theano.tensor.type
import
TensorType
@gof.local_optimizer
([
SparseBlockGemv
],
inplace
=
True
)
...
...
@@ -591,7 +586,7 @@ def local_abstractconv_check(node):
AbstractConv3d_gradInputs
,
),
):
raise
gof
.
opt
.
LocalMetaOptimizerSkipAssertionError
(
raise
LocalMetaOptimizerSkipAssertionError
(
"
%
s Theano optimization failed: there is no implementation "
"available supporting the requested options. Did you exclude "
'both "conv_dnn" and "conv_gemm" from the optimizer? If on GPU, '
...
...
@@ -603,7 +598,7 @@ def local_abstractconv_check(node):
optdb
.
register
(
"AbstractConvCheck"
,
opt
.
in2out
(
local_abstractconv_check
,
name
=
"AbstractConvCheck"
),
in2out
(
local_abstractconv_check
,
name
=
"AbstractConvCheck"
),
48.7
,
"fast_compile"
,
"fast_run"
,
...
...
theano/tensor/nnet/sigm.py
浏览文件 @
62fa59c9
...
...
@@ -13,11 +13,13 @@ import numpy as np
import
theano
from
theano
import
config
,
gof
,
printing
,
scalar
from
theano.gof.opt
import
copy_stack_trace
from
theano.printing
import
pprint
from
theano.tensor
import
basic
as
tensor
from
theano.tensor
import
elemwise
,
opt
,
NotScalarConstantError
from
theano.tensor
import
elemwise
,
opt
from
theano.tensor.basic
import
NotScalarConstantError
from
theano.tensor.type
import
values_eq_approx_remove_inf
from
theano.gof.opt
import
copy_stack_trace
############
#
...
...
@@ -155,9 +157,10 @@ class ScalarSigmoid(scalar.UnaryScalarOp):
val_hard
=
hard_sigmoid
(
data
)
.
eval
()
val_ultra
=
ultra_fast_sigmoid
(
data
)
.
eval
()
import
matplotlib.pyplot
as
plt
import
os
import
matplotlib.pyplot
as
plt
fig
=
plt
.
figure
()
ax
=
fig
.
add_subplot
(
111
)
ax
.
plot
(
data
,
val
)
# , 'o-')
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论