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

What is the char class for? #18

Open
chanind opened this issue Jul 20, 2021 · 4 comments
Open

What is the char class for? #18

chanind opened this issue Jul 20, 2021 · 4 comments

Comments

@chanind
Copy link

chanind commented Jul 20, 2021

It looks like the generator model includes a character classifier output, which classifies the character to one of 52 one-hot values. The number 52 is hardcoded: https://github.com/hologerry/Attr2Font/blob/master/model.py#L231. What is this for? The discriminator takes in a character class param, but then ignores it and never references it https://github.com/hologerry/Attr2Font/blob/master/model.py#L367. Is the char class being in this algorithm a mistake, or is it necessary for the font generation to function? If so, why?

@hologerry
Copy link
Owner

Thanks for your interest.
The number 52 represents 26 upper and lower case letters.
In Generator, the charclass is used for the content supervision, i.e., which character is for the input.
In Discriminator, the charclass is added during the exploration process, but actually ended up being useless, please just ignore it.

@chanind
Copy link
Author

chanind commented Jul 21, 2021

The hardcoded 52 makes sense as 26x2. So that hardcoded value would need to be changed to use this for a real font, as real fonts have more than 52 glyphs? I guess I'm still confused what the charclass is for. If I remove this item from the generator it still seems to work. Am I missing something?

@hologerry
Copy link
Owner

Yes, the 52 need to be changed according to the number of glyphs in practice.
We did not pass the charclass in generator, did you mean the discriminator?
The charclass is only used for the content loss (softmax with the content_logit:

return out, content_logits
,
loss_char_A = criterion_ce(content_logits_A, charclass_A.view(charclass_A.size(0))) # +
).
So, the parameter charclass passed in discriminator is NOT necessary, should be cleaned, just ignore it.

@chanind
Copy link
Author

chanind commented Jul 21, 2021

yes that makes sense. Sorry when I said removing from the generator I meant removing the fc layer and content_logits, as well as the criterion_ce and loss_char stuff entirely. It seems like if I remove everything related to the char class and content_logits this it still works. Is that correct / expected?

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