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

pred = torch.argmax(input[:, :2], dim=1) #18

Closed
Note-Liu opened this issue Jul 16, 2021 · 7 comments
Closed

pred = torch.argmax(input[:, :2], dim=1) #18

Note-Liu opened this issue Jul 16, 2021 · 7 comments

Comments

@Note-Liu
Copy link

In model.py:

def accuracy_gender(input, targs):
pred = torch.argmax(input[:, :2], dim=1)
y = targs[:, 0]
return torch.sum(pred == y)

I want to know why not pred = input[:,:1] ?
I think first two columns of input are genders and races.

@sajjjadayobi
Copy link
Owner

sajjjadayobi commented Jul 16, 2021

first two columns are logits for (male, female) and the second one is for Age

as you can see I've used last index (aka 3) for age

def l1loss_age(input, targs):
    return F.l1_loss(input[:, -1], targs[:, -1]).mean()

@Note-Liu
Copy link
Author

first two columns are logits for (male, female) and the second one is for Age

as you can see I've used last index (aka 3) for age

def l1loss_age(input, targs):
    return F.l1_loss(input[:, -1], targs[:, -1]).mean()

Thanks for your reply!

@Note-Liu
Copy link
Author

first two columns are logits for (male, female) and the second one is for Age
as you can see I've used last index (aka 3) for age

def l1loss_age(input, targs):
    return F.l1_loss(input[:, -1], targs[:, -1]).mean()

Thanks for your reply!

In Age & Gender Estimation,did you use the original image of UTKFace Dataset to train ShufflenetFull ?

@sajjjadayobi
Copy link
Owner

Although I do not know what you mean by original, I train on UTKFace Dataset with ShufflenetFull as the backbone

@Note-Liu
Copy link
Author

Although I do not know what you mean by original, I train on UTKFace Dataset with ShufflenetFull as the backbone

Thanks!I see what you mean.
I have another question to ask:

def multitask_loss(input, target):
input_gender = input[:, :2]
input_age = input[:, -1]
loss_gender = F.cross_entropy(input_gender, target[:, 0].long())
loss_age = F.l1_loss(input_age, target[:, 2])

return loss_gender / (.16) + loss_age * 2

I want to know "loss_gender / (.16) + loss_age * 2",how is the ratio determined? Is it from the experiment?

@sajjjadayobi
Copy link
Owner

Yep, the loss ratio results from some experiments
Depending on how much you care about gender detection or age estimation.

@Note-Liu
Copy link
Author

Yep, the loss ratio results from some experiments
Depending on how much you care about gender detection or age estimation.

Thank you for your patience!

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

2 participants