mindcv.models.layers.activation 源代码

"""
Custom operators.
"""

from mindspore import nn

__all__ = ['Swish']


[文档]class Swish(nn.Cell): """ Swish activation function: x * sigmoid(x). Args: None Return: Tensor Example: >>> x = Tensor(((20, 16), (50, 50)), mindspore.float32) >>> Swish()(x) """ def __init__(self): super().__init__() self.result = None self.sigmoid = nn.Sigmoid()
[文档] def construct(self, x): result = x * self.sigmoid(x) return result