dailenson / SDT

This repository is the official implementation of Disentangling Writer and Character Styles for Handwriting Generation (CVPR 2023)
MIT License
968 stars 82 forks source link

Only have positive pairs? #27

Open Meimeiainaonao opened 10 months ago

Meimeiainaonao commented 10 months ago

Thanks for your sharing!

May I have a question about NCELoss? I cannot find how to choose the negative samples in your code. I only found how to choose the positive pairs in your ''random_double_sampling'' and how to calculate the NCELoss by using the positive pairs. So May I know where is the part I need?

Thanks for your help.

image

dailenson commented 10 months ago

Hi~ Thanks for your attention. As mentioned in our paper, our GlyphNCE independently samples positive pairs within a character, and samples negative samples from other characters, as illustrated in Figure 3. In our code implementation, we use the in-batch contrastive loss where the negative samples are all characters in one batch except for the anchor sample. More implementation details can be seen in SupConLoss.

Meimeiainaonao commented 10 months ago

Wow, Thanks for your answer! I got it!