sciai.architecture.AdaptActivation
- class sciai.architecture.AdaptActivation(activation, a, scale)[源代码]
具有可训练参数和固定尺度的自适应激活函数。 自适应激活函数详情请查看: Adaptive activation functions accelerate convergence in deep and physics-informed neural networks 和 Locally adaptive activationfunctions with slope recoveryfor deep and physics-informedneural network 。
- 参数:
activation (Union[str, Cell, Primitive, function]) - 激活函数。
a (Union[Number, Tensor, Parameter]) - 可训练参数 a 。
scale (Union[Number, Tensor]) - 固定比例参数。
- 输入:
x (Tensor) - AdaptActivation的输入。
- 输出:
Tensor,shape与 x 一致的被激活的输出。
- 异常:
TypeError - 如果输入类型不正确。
- 支持平台:
GPU
CPU
Ascend
样例:
>>> import mindspore as ms >>> from mindspore import ops, nn >>> from sciai.architecture import AdaptActivation >>> a = ms.Tensor(0.1, ms.float32) >>> net = AdaptActivation(nn.Tanh(), a=a, scale=10) >>> x = ops.ones((2, 3), ms.float32) >>> y = net(x) >>> print(y) [[0.7615942 0.7615942 0.7615942] [0.7615942 0.7615942 0.7615942]]