Skip to content
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

How to define focal loss in train_val.prototxt, two classes with softmax? #12

Open
wvinzh opened this issue May 5, 2018 · 4 comments
Open

Comments

@wvinzh
Copy link

wvinzh commented May 5, 2018

I'm using Focal Loss to train a two-class model.
my prototxt is like this:
layer {
bottom: "pool5"
top: "fc2"
name: "fc2"
type: "InnerProduct"
inner_product_param {
num_output: 2
}
}
layer {
bottom: "fc2"
top: "prob"
name: "prob"
type: "Softmax"
}

layer {
name: "loss_cls"
type: "FocalLoss"
bottom: "prob"
bottom: "label"
propagate_down: 1
propagate_down: 0
top: "loss_cls"
include { phase: TRAIN }
loss_weight: 1
loss_param { ignore_label: -1 normalize: true }
focal_loss_param { alpha: 0.5 gamma: 2 }
}

but it went wrong :
bottom[0]->count() == bottom[1]->count() (16 vs. 8) SIGMOID_CROSS_ENTROPY_LOSS layer inputs must have the same count.

I think maybe this Focal loss is using simoid, so how can i use it with softmax??

thanks!

@wvinzh wvinzh changed the title How 同哦 How to define focal loss in train_val.prototxt May 5, 2018
@wvinzh wvinzh changed the title How to define focal loss in train_val.prototxt How to define focal loss in train_val.prototxt, two classes with softmax? May 5, 2018
@lyj0823
Copy link

lyj0823 commented Jun 15, 2018

Have you solved this problem,please help me ,thanks!

@JackyWang-001
Copy link

JackyWang-001 commented Nov 16, 2018

Delete the Softmax layer, beacuse it is used in deploy.prototxt, and change bottom: "prob"to bottom: "fc2" in FocalLoss layer.

@ngunauj
Copy link

ngunauj commented Jan 2, 2019

why ignore label: -1 ??

@1343464520
Copy link

@wvinzh @lyj0823 @Jacky3213 also have this problem. And i try to change the num_output of fc layer from 2 to 1. It does work, but the acc is very low...just 60%... So, how do you solve it? Please help, Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants