__init__.py 10.2 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 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
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
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
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
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
from .layer.common import Pad1D  # noqa: F401
from .layer.common import Pad2D  # noqa: F401
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
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

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
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
from .layer.loss import CTCLoss  # noqa: F401
from .layer.loss import SmoothL1Loss  # noqa: F401
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
from .layer.container import LayerDict  # noqa: F401

129 130
from .utils.spectral_norm_hook import spectral_norm

131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
# TODO: remove loss, keep it for too many used in unitests
from .layer import loss  # noqa: F401
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

from . import utils  # noqa: F401
from . import functional  # noqa: F401
from . import initializer  # noqa: F401

#TODO: remove 'diag_embed', 'remove_weight_norm', 'weight_norm' months later.
import paddle.utils.deprecated as deprecated


@deprecated(
    since="2.0.0",
    update_to="paddle.nn.funcitional.diag_embed",
149 150
    level=1,
    reason="diag_embed in paddle.nn will be removed in future")
151 152 153 154 155 156 157 158 159 160
def diag_embed(*args):
    '''
        alias name of paddle.nn.functional.diag_embed
    '''
    return functional.diag_embed(*args)


@deprecated(
    since="2.0.0",
    update_to="paddle.nn.utils.remove_weight_norm",
161 162
    level=1,
    reason="remove_weight_norm in paddle.nn will be removed in future")
163 164 165 166 167 168 169 170 171 172
def remove_weight_norm(*args):
    '''
        alias name of paddle.nn.utils.remove_weight_norm
    '''
    return utils.remove_weight_norm(*args)


@deprecated(
    since="2.0.0",
    update_to="paddle.nn.utils.weight_norm",
173 174
    level=1,
    reason="weight_norm in paddle.nn will be removed in future")
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 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
def weight_norm(*args):
    '''
        alias name of paddle.nn.utils.weight_norm
    '''
    return utils.weight_norm(*args)


__all__ = [     #noqa
           'BatchNorm',
           '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'
           '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',
           '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',
           'PixelShuffle',
           'ELU',
           'ReLU6'
]