-
Notifications
You must be signed in to change notification settings - Fork 574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
怎么将BNNeck与Focal Loss结合? #214
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
我尝试将您在reid-strong-baseline/modeling/baseline.py下关于bnneck的部分代码移植到mmclassification中,因为做的是细粒度图像分类,这里采用mmclassification的focal loss解决样本不平衡的问题。
mmclassification中的focal loss代码如下:
我训练的时候focal loss都按官方给的参数默认配置,即gamma=2.0,alpha=0.25。除此之外,batchsize是64,类别数是9691。
我发现,以Resnet50做beckbone,如果加入BNNeck,将BNNeck的fc层产生的特征作为pred导入到上述focal loss代码中的sigmoid_focal_loss()函数,训练生成的结果如下:
这里加了BNNeck的代码(修改了mmclassification相应head代码)如下:
如果不加BNNeck,直接将Resnet50的fc层输出特征作为pred导入到之前focal loss代码中的sigmoid_focal_loss()函数,训练生成的结果如下:
这里不加BNNeck的代码(修改了mmclassification相应head代码)如下:
我仔细检查了加入BNNeck的移植代码部分,确定没有问题后,有个疑问,就是为什么加入了BNNeck所训练出的focal loss是1000多?相比不加BNNeck的差别巨大?我的conda环境配置如下:
想请教下这是什么原因引起的?以及怎么才能将BNNeck与focal loss很好的结合在一起?
The text was updated successfully, but these errors were encountered: