1,常用的激活函数

2,Mish激活函数
# -*- coding: utf-8 -*-
import torch
import torch.nn as nn
import torch.nn.functional as F
from matplotlib import pyplot as plt
class Mish(nn.Module):
def __init__(self):
super().__init__()
print("Mish activation loaded...")
def forward(self,x):
x = x * (torch.tanh(F.softplus(x)))
return x
mish = Mish()
x = torch.linspace(-10,10,1000)
y = mish(x)
plt.plot(x,y)
plt.grid()
plt.show()
本文详细介绍了Mish激活函数的原理与特性,并通过PyTorch实现了Mish激活函数,展示了其在不同输入范围内的行为表现。Mish激活函数是一种自门控的Swish激活函数变种,能够提升神经网络的性能。

2849





