__init__.py 10.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#   Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

15
# TODO: import all neural network related api under this directory,
16
# including layers, linear, conv, rnn etc.
17 18
from .layer.container import LayerList  # noqa: F401
from .layer.container import ParameterList  # noqa: F401
19
from .layer.container import Sequential  # noqa: F401
Z
zhiboniu 已提交
20

Z
zhiboniu 已提交
21 22 23 24 25
from .clip import ClipGradByGlobalNorm  # noqa: F401
from .clip import ClipGradByNorm  # noqa: F401
from .clip import ClipGradByValue  # noqa: F401
from .decode import BeamSearchDecoder  # noqa: F401
from .decode import dynamic_decode  # noqa: F401
26
from .layer.activation import CELU  # noqa: F401
Z
zhiboniu 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
from .layer.activation import ELU  # noqa: F401
from .layer.activation import GELU  # noqa: F401
from .layer.activation import Tanh  # noqa: F401
from .layer.activation import Hardshrink  # noqa: F401
from .layer.activation import Hardswish  # noqa: F401
from .layer.activation import Hardtanh  # noqa: F401
from .layer.activation import PReLU  # noqa: F401
from .layer.activation import ReLU  # noqa: F401
from .layer.activation import ReLU6  # noqa: F401
from .layer.activation import SELU  # noqa: F401
from .layer.activation import Silu  # noqa: F401
from .layer.activation import LeakyReLU  # noqa: F401
from .layer.activation import Sigmoid  # noqa: F401
from .layer.activation import Hardsigmoid  # noqa: F401
from .layer.activation import LogSigmoid  # noqa: F401
from .layer.activation import Softmax  # noqa: F401
43
from .layer.activation import Softmax2D  # noqa: F401
Z
zhiboniu 已提交
44 45 46 47
from .layer.activation import Softplus  # noqa: F401
from .layer.activation import Softshrink  # noqa: F401
from .layer.activation import Softsign  # noqa: F401
from .layer.activation import Swish  # noqa: F401
48
from .layer.activation import Mish  # noqa: F401
Z
zhiboniu 已提交
49 50 51 52
from .layer.activation import Tanhshrink  # noqa: F401
from .layer.activation import ThresholdedReLU  # noqa: F401
from .layer.activation import LogSoftmax  # noqa: F401
from .layer.activation import Maxout  # noqa: F401
53
from .layer.activation import RReLU  # noqa: F401
Z
zhiboniu 已提交
54 55
from .layer.common import Pad1D  # noqa: F401
from .layer.common import Pad2D  # noqa: F401
56
from .layer.common import ZeroPad2D  # noqa: F401
Z
zhiboniu 已提交
57 58 59 60
from .layer.common import Pad3D  # noqa: F401
from .layer.common import CosineSimilarity  # noqa: F401
from .layer.common import Embedding  # noqa: F401
from .layer.common import Linear  # noqa: F401
S
shiyutang 已提交
61
from .layer.common import Identity  # noqa: F401
Z
zhiboniu 已提交
62 63 64 65 66 67 68 69 70 71
from .layer.common import Flatten  # noqa: F401
from .layer.common import Upsample  # noqa: F401
from .layer.common import UpsamplingNearest2D  # noqa: F401
from .layer.common import UpsamplingBilinear2D  # noqa: F401
from .layer.common import Bilinear  # noqa: F401
from .layer.common import Dropout  # noqa: F401
from .layer.common import Dropout2D  # noqa: F401
from .layer.common import Dropout3D  # noqa: F401
from .layer.common import AlphaDropout  # noqa: F401
from .layer.common import Unfold  # noqa: F401
X
xiaoting 已提交
72
from .layer.common import Fold  # noqa: F401
Z
zhiboniu 已提交
73 74 75 76 77 78 79

from .layer.pooling import AvgPool1D  # noqa: F401
from .layer.pooling import AvgPool2D  # noqa: F401
from .layer.pooling import AvgPool3D  # noqa: F401
from .layer.pooling import MaxPool1D  # noqa: F401
from .layer.pooling import MaxPool2D  # noqa: F401
from .layer.pooling import MaxPool3D  # noqa: F401
80
from .layer.pooling import MaxUnPool1D  # noqa: F401
81
from .layer.pooling import MaxUnPool2D  # noqa: F401
82
from .layer.pooling import MaxUnPool3D  # noqa: F401
Z
zhiboniu 已提交
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
from .layer.pooling import AdaptiveAvgPool1D  # noqa: F401
from .layer.pooling import AdaptiveAvgPool2D  # noqa: F401
from .layer.pooling import AdaptiveAvgPool3D  # noqa: F401
from .layer.pooling import AdaptiveMaxPool1D  # noqa: F401
from .layer.pooling import AdaptiveMaxPool2D  # noqa: F401
from .layer.pooling import AdaptiveMaxPool3D  # noqa: F401

from .layer.conv import Conv1D  # noqa: F401
from .layer.conv import Conv2D  # noqa: F401
from .layer.conv import Conv3D  # noqa: F401
from .layer.conv import Conv1DTranspose  # noqa: F401
from .layer.conv import Conv2DTranspose  # noqa: F401
from .layer.conv import Conv3DTranspose  # noqa: F401

from .layer.loss import BCEWithLogitsLoss  # noqa: F401
from .layer.loss import CrossEntropyLoss  # noqa: F401
from .layer.loss import HSigmoidLoss  # noqa: F401
from .layer.loss import MSELoss  # noqa: F401
from .layer.loss import L1Loss  # noqa: F401
from .layer.loss import NLLLoss  # noqa: F401
from .layer.loss import BCELoss  # noqa: F401
from .layer.loss import KLDivLoss  # noqa: F401
from .layer.loss import MarginRankingLoss  # noqa: F401
Y
yangguohao 已提交
106
from .layer.loss import MultiLabelSoftMarginLoss
Z
zhiboniu 已提交
107
from .layer.loss import CTCLoss  # noqa: F401
H
Hui Zhang 已提交
108
from .layer.loss import RNNTLoss  # noqa: F401
Z
zhiboniu 已提交
109
from .layer.loss import SmoothL1Loss  # noqa: F401
110
from .layer.loss import HingeEmbeddingLoss  # noqa: F401
111
from .layer.loss import CosineEmbeddingLoss  # noqa: F401
Y
yangguohao 已提交
112
from .layer.loss import MultiMarginLoss
Y
yangguohao 已提交
113
from .layer.loss import TripletMarginWithDistanceLoss
Y
yangguohao 已提交
114
from .layer.loss import TripletMarginLoss
115
from .layer.loss import SoftMarginLoss
Z
zhiboniu 已提交
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
from .layer.norm import BatchNorm  # noqa: F401
from .layer.norm import SyncBatchNorm  # noqa: F401
from .layer.norm import GroupNorm  # noqa: F401
from .layer.norm import LayerNorm  # noqa: F401
from .layer.norm import SpectralNorm  # noqa: F401
from .layer.norm import InstanceNorm1D  # noqa: F401
from .layer.norm import InstanceNorm2D  # noqa: F401
from .layer.norm import InstanceNorm3D  # noqa: F401
from .layer.norm import BatchNorm1D  # noqa: F401
from .layer.norm import BatchNorm2D  # noqa: F401
from .layer.norm import BatchNorm3D  # noqa: F401
from .layer.norm import LocalResponseNorm  # noqa: F401

from .layer.rnn import RNNCellBase  # noqa: F401
from .layer.rnn import SimpleRNNCell  # noqa: F401
from .layer.rnn import LSTMCell  # noqa: F401
from .layer.rnn import GRUCell  # noqa: F401
from .layer.rnn import RNN  # noqa: F401
from .layer.rnn import BiRNN  # noqa: F401
from .layer.rnn import SimpleRNN  # noqa: F401
from .layer.rnn import LSTM  # noqa: F401
from .layer.rnn import GRU  # noqa: F401

from .layer.transformer import MultiHeadAttention  # noqa: F401
from .layer.transformer import TransformerEncoderLayer  # noqa: F401
from .layer.transformer import TransformerEncoder  # noqa: F401
from .layer.transformer import TransformerDecoderLayer  # noqa: F401
from .layer.transformer import TransformerDecoder  # noqa: F401
from .layer.transformer import Transformer  # noqa: F401
from .layer.distance import PairwiseDistance  # noqa: F401

from .layer.vision import PixelShuffle  # noqa: F401
148
from .layer.vision import PixelUnshuffle  # noqa: F401
149
from .layer.vision import ChannelShuffle  # noqa: F401
Z
zhiboniu 已提交
150 151
from .layer.container import LayerDict  # noqa: F401

152 153
from .layer.layers import Layer  # noqa: F401

W
wangna11BD 已提交
154 155
from .utils.spectral_norm_hook import spectral_norm

Z
zhiboniu 已提交
156 157 158 159 160 161
# TODO: remove loss, keep it for too many used in unitests
from .layer import loss  # noqa: F401

from . import utils  # noqa: F401
from . import functional  # noqa: F401
from . import initializer  # noqa: F401
162
from . import quant  # noqa: F401
Z
zhiboniu 已提交
163

Y
yangguohao 已提交
164
# TODO: remove 'diag_embed', 'remove_weight_norm', 'weight_norm' months later.
Z
zhiboniu 已提交
165 166 167
import paddle.utils.deprecated as deprecated


168 169 170 171 172 173
@deprecated(
    since="2.0.0",
    update_to="paddle.nn.funcitional.diag_embed",
    level=1,
    reason="diag_embed in paddle.nn will be removed in future",
)
Z
zhiboniu 已提交
174 175
def diag_embed(*args):
    '''
176
    alias name of paddle.nn.functional.diag_embed
Z
zhiboniu 已提交
177 178 179 180
    '''
    return functional.diag_embed(*args)


181 182 183 184 185 186
@deprecated(
    since="2.0.0",
    update_to="paddle.nn.utils.remove_weight_norm",
    level=1,
    reason="remove_weight_norm in paddle.nn will be removed in future",
)
Z
zhiboniu 已提交
187 188
def remove_weight_norm(*args):
    '''
189
    alias name of paddle.nn.utils.remove_weight_norm
Z
zhiboniu 已提交
190 191 192 193
    '''
    return utils.remove_weight_norm(*args)


194 195 196 197 198 199
@deprecated(
    since="2.0.0",
    update_to="paddle.nn.utils.weight_norm",
    level=1,
    reason="weight_norm in paddle.nn will be removed in future",
)
Z
zhiboniu 已提交
200 201
def weight_norm(*args):
    '''
202
    alias name of paddle.nn.utils.weight_norm
Z
zhiboniu 已提交
203 204 205 206
    '''
    return utils.weight_norm(*args)


Y
yangguohao 已提交
207
__all__ = [  # noqa
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
    'BatchNorm',
    'CELU',
    'GroupNorm',
    'LayerNorm',
    'SpectralNorm',
    'BatchNorm1D',
    'BatchNorm2D',
    'BatchNorm3D',
    'InstanceNorm1D',
    'InstanceNorm2D',
    'InstanceNorm3D',
    'SyncBatchNorm',
    'LocalResponseNorm',
    'Embedding',
    'Linear',
    'Upsample',
    'UpsamplingNearest2D',
    'UpsamplingBilinear2D',
    'Pad1D',
    'Pad2D',
    'Pad3D',
    'CosineSimilarity',
    'Dropout',
    'Dropout2D',
    'Dropout3D',
    'Bilinear',
    'AlphaDropout',
    'Unfold',
    'Fold',
    'RNNCellBase',
    'SimpleRNNCell',
    'LSTMCell',
    'GRUCell',
    'RNN',
    'BiRNN',
    'SimpleRNN',
    'LSTM',
    'GRU',
    'dynamic_decode',
    'MultiHeadAttention',
    'Maxout',
    'Softsign',
    'Transformer',
    'MSELoss',
    'LogSigmoid',
    'BeamSearchDecoder',
    'ClipGradByNorm',
    'ReLU',
    'PairwiseDistance',
    'BCEWithLogitsLoss',
    'SmoothL1Loss',
    'MaxPool3D',
    'AdaptiveMaxPool2D',
    'Hardshrink',
    'Softplus',
    'KLDivLoss',
    'AvgPool2D',
    'L1Loss',
    'LeakyReLU',
    'AvgPool1D',
    'AdaptiveAvgPool3D',
    'AdaptiveMaxPool3D',
    'NLLLoss',
    'Conv1D',
    'Sequential',
    'Hardswish',
    'Conv1DTranspose',
    'AdaptiveMaxPool1D',
    'TransformerEncoder',
    'Softmax',
    'Softmax2D',
    'ParameterList',
    'Conv2D',
    'Softshrink',
    'Hardtanh',
    'TransformerDecoderLayer',
    'CrossEntropyLoss',
    'GELU',
    'SELU',
    'Silu',
    'Conv2DTranspose',
    'CTCLoss',
H
Hui Zhang 已提交
290
    'RNNTLoss',
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
    'ThresholdedReLU',
    'AdaptiveAvgPool2D',
    'MaxPool1D',
    'Layer',
    'TransformerDecoder',
    'Conv3D',
    'Tanh',
    'Conv3DTranspose',
    'Flatten',
    'AdaptiveAvgPool1D',
    'Tanhshrink',
    'HSigmoidLoss',
    'PReLU',
    'TransformerEncoderLayer',
    'AvgPool3D',
    'MaxPool2D',
    'MarginRankingLoss',
    'LayerList',
    'ClipGradByValue',
    'BCELoss',
    'Hardsigmoid',
    'ClipGradByGlobalNorm',
    'LogSoftmax',
    'Sigmoid',
    'Swish',
    'Mish',
    'PixelShuffle',
    'PixelUnshuffle',
    'ChannelShuffle',
    'ELU',
    'ReLU6',
    'LayerDict',
    'ZeroPad2D',
    'MaxUnPool1D',
    'MaxUnPool2D',
    'MaxUnPool3D',
Y
yangguohao 已提交
327
    'MultiLabelSoftMarginLoss',
328 329
    'HingeEmbeddingLoss',
    'Identity',
330
    'CosineEmbeddingLoss',
331
    'RReLU',
Y
yangguohao 已提交
332
    'MultiMarginLoss',
Y
yangguohao 已提交
333
    'TripletMarginWithDistanceLoss',
Y
yangguohao 已提交
334
    'TripletMarginLoss',
335
    'SoftMarginLoss',
Z
zhiboniu 已提交
336
]