from torch.nn import Linear,Conv2d,BatchNorm1d,BatchNorm2d,PReLU,ReLU,Sigmoid,Dropout,MaxPool2d,AdaptiveAvgPool2d,Sequential,Module,Parameter
import torch
from collections import namedtuple
import math
class Flatten(Module):
def forward(self, input):
return input.view(input.size(0), -1)
def l2_norm(input,axis=1):
norm = torch.norm(input,2,axis,True)
output = torch.div(input, norm)
return output
class SEModule(Module):
def __init__(self,channels,reduction):
super(SEModule,self).__init__()
self.avg_pool =AdaptiveAvgPool2d(1)
self.fc1 = Conv2d(
channels,channels//reduction,kernel_size=1,padding=0,bias=False
)
self.relu = ReLU(inplace=True)
self.fc2 = Conv2d(channels//reduction,channels,kernel_size=1,padding=0,bias=False)
self.sigmoid =Sigmoid()
def forward(self,x):
module_input = x
x =self.avg_pool(x)
x = self.fc1(x)
x = self.relu(x)
x = self.fc2(x)
x = self.sigmoid(x)
return module_input * x
class bottleneck_IR
arcface backbone
最新推荐文章于 2024-06-17 11:46:05 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)