本文共 1770 字,大约阅读时间需要 5 分钟。
#coding=utf-8 from collections import OrderedDict import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import init import timedef _make_divisible(v, divisor, min_value=None): """This function is taken from the original tf repo. It ensures that all layers have a channel number that is divisible by 8 It can be seen here: https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet/mobilenet.py :param v: :param divisor: :param min_value: (optional) :return: """ if min_value is None: min_value = divisor new_v = max(min_value, int(v + divisor / 2.0) // divisor * divisor) # Make sure that round down does not go down by more than 10%. if new_v < 0.9 * v: new_v += divisor return new_v class SELayer(nn.Module): def __init__(self, channel, reduction=16): # ?????? super(SELayer, self).__init__() # ????????? self.channel = channel # ???????? self.reduction = reduction def forward(self, x): # ?????? # ??x # ... (??????) # ???????? return x def __repr__(self): # __repr__?? return f"SELayer({self.channel}d, reduction={self.reduction})"
????????????????????
???????????????????????????????
转载地址:http://vrtk.baihongyu.com/