arcface-pytorch
arcface-pytorch copied to clipboard
为什么我对模型backbone进行了修改,训练时候一直为0的准确率呢,就比如说我采用了mobileNetV4这个模型,
请问为什么我采用这这个模型,我将模型最后一层的输出改为嵌入向量维度不就可以吗,为什么准确率一直是0呢,请问问题出在哪里呢,我看着B导mobileNetV1的模型也是这么做的啊,为啥这么做就不可以呢
class MobileNetV4(nn.Module): def init(self, model,embedding_size=128,dropout_keep_prob=0.5, pretrained=False): # MobileNetV4ConvSmall MobileNetV4ConvMedium MobileNetV4ConvLarge # MobileNetV4HybridMedium MobileNetV4HybridLarge """Params to initiate MobilenNetV4 Args: model : support 5 types of models as indicated in "https://github.com/tensorflow/models/blob/master/official/vision/modeling/backbones/mobilenet.py" """ super().init() assert model in MODEL_SPECS.keys() self.model = model self.spec = MODEL_SPECS[self.model]
# conv0
self.conv0 = build_blocks(self.spec['conv0'])
# layer1
self.layer1 = build_blocks(self.spec['layer1'])
# layer2
self.layer2 = build_blocks(self.spec['layer2'])
# layer3
self.layer3 = build_blocks(self.spec['layer3'])
# layer4
self.layer4 = build_blocks(self.spec['layer4'])
# layer5
self.layer5 = build_blocks(self.spec['layer5'])
self.layer6 = nn.Conv2d(1280,512,kernel_size=1)
#embeding
self.layer7 = nn.Linear(512*49, embedding_size)
# self.layer6 = nn.Conv2d(1280,embedding_size,1)
self.features = nn.BatchNorm1d(embedding_size, eps=1e-05)
self.dropout = nn.Dropout(p=dropout_keep_prob, inplace=True)
def forward(self, x):
x0 = self.conv0(x)
x1 = self.layer1(x0)
x2 = self.layer2(x1)
x3 = self.layer3(x2)
x4 = self.layer4(x3)
x5 = self.layer5(x4)
x6 = self.layer6(x5)
x7 = torch.flatten(x6, 1)
# 或者 x5 = x5.view(x5.size(0), -1)
x8 = self.layer7(x7)
# x6 = self.features(x6)
print(x8.shape)
return x8
你好,请问你解决这个问题了吗?我也遇到这个问题了,backbone换成efficient训练的时候acc一直为0,loss也不下降。测试过梯度是正常的,数据也没问题
不好意思,我有些忘记了,好像是因为使用的损失里它有一行代码是出现了问题,比如说arc或者cos的损失,好像是归零行出现了问题。具体我也忘记了
发自我的iPhone
------------------ 原始邮件 ------------------ 发件人: x710777335 @.> 发送时间: 2025年4月30日 16:44 收件人: bubbliiiing/arcface-pytorch @.> 抄送: yulongPan @.>, Author @.> 主题: Re: [bubbliiiing/arcface-pytorch] 为什么我对模型backbone进行了修改,训练时候一直为0的准确率呢,就比如说我采用了mobileNetV4这个模型, (Issue #38)
x710777335 left a comment (bubbliiiing/arcface-pytorch#38)
你好,请问你解决这个问题了吗?我也遇到这个问题了,backbone换成efficient训练的时候acc一直为0,loss也不下降。测试过梯度是正常的,数据也没问题
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>