__init__.py 10.7 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.
Z
zhiboniu 已提交
17 18 19 20 21
from ..fluid.dygraph.layers import Layer  # noqa: F401
from ..fluid.dygraph.container import LayerList  # noqa: F401
from ..fluid.dygraph.container import ParameterList  # noqa: F401
from ..fluid.dygraph.container import Sequential  # noqa: F401

Z
zhiboniu 已提交
22 23 24 25 26
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
27
from .layer.activation import CELU  # noqa: F401
Z
zhiboniu 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
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
44
from .layer.activation import Softmax2D  # noqa: F401
Z
zhiboniu 已提交
45 46 47 48
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
49
from .layer.activation import Mish  # noqa: F401
Z
zhiboniu 已提交
50 51 52 53
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
54
from .layer.activation import RReLU  # noqa: F401
Z
zhiboniu 已提交
55 56
from .layer.common import Pad1D  # noqa: F401
from .layer.common import Pad2D  # noqa: F401
57
from .layer.common import ZeroPad2D  # noqa: F401
Z
zhiboniu 已提交
58 59 60 61
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 已提交
62
from .layer.common import Identity  # noqa: F401
Z
zhiboniu 已提交
63 64 65 66 67 68 69 70 71 72
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 已提交
73
from .layer.common import Fold  # noqa: F401
Z
zhiboniu 已提交
74 75 76 77 78 79 80

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
81
from .layer.pooling import MaxUnPool1D  # noqa: F401
82
from .layer.pooling import MaxUnPool2D  # noqa: F401
83
from .layer.pooling import MaxUnPool3D  # noqa: F401
Z
zhiboniu 已提交
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
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 已提交
107
from .layer.loss import MultiLabelSoftMarginLoss
Z
zhiboniu 已提交
108 109
from .layer.loss import CTCLoss  # noqa: F401
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 TripletMarginWithDistanceLoss
Y
yangguohao 已提交
113
from .layer.loss import TripletMarginLoss
Z
zhiboniu 已提交
114 115 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
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
146
from .layer.vision import PixelUnshuffle  # noqa: F401
147
from .layer.vision import ChannelShuffle  # noqa: F401
Z
zhiboniu 已提交
148 149
from .layer.container import LayerDict  # noqa: F401

W
wangna11BD 已提交
150 151
from .utils.spectral_norm_hook import spectral_norm

Z
zhiboniu 已提交
152 153 154 155 156 157
# 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
158
from . import quant  # noqa: F401
Z
zhiboniu 已提交
159

Y
yangguohao 已提交
160
# TODO: remove 'diag_embed', 'remove_weight_norm', 'weight_norm' months later.
Z
zhiboniu 已提交
161 162 163
import paddle.utils.deprecated as deprecated


164 165 166 167
@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 已提交
168 169 170 171 172 173 174
def diag_embed(*args):
    '''
        alias name of paddle.nn.functional.diag_embed
    '''
    return functional.diag_embed(*args)


175 176 177 178
@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 已提交
179 180 181 182 183 184 185
def remove_weight_norm(*args):
    '''
        alias name of paddle.nn.utils.remove_weight_norm
    '''
    return utils.remove_weight_norm(*args)


186 187 188 189
@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 已提交
190 191 192 193 194 195 196
def weight_norm(*args):
    '''
        alias name of paddle.nn.utils.weight_norm
    '''
    return utils.weight_norm(*args)


Y
yangguohao 已提交
197
__all__ = [  # noqa
198 199 200 201 202 203 204 205 206 207 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 290 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
    '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',
    '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 已提交
316
    'MultiLabelSoftMarginLoss',
317 318
    'HingeEmbeddingLoss',
    'Identity',
319
    'CosineEmbeddingLoss',
320
    'RReLU',
Y
yangguohao 已提交
321
    'TripletMarginWithDistanceLoss',
Y
yangguohao 已提交
322
    'TripletMarginLoss',
Z
zhiboniu 已提交
323
]