QinbinLi / MOON

Model-Contrastive Federated Learning (CVPR 2021)
MIT License
263 stars 56 forks source link

Quesiton for code #1

Closed xutting123 closed 3 years ago

xutting123 commented 3 years ago

Hi, I have read your paper and code and found it to be an interesting work!

I have a question. In your code,

loss2 = mu * criterion(logits, labels) # (main.py line311).

I know it is uesd to caculate the con_loss (Eq.3 in your paper), but why it is implemented by cross-entropy loss with labels (zeros tensor)?

QinbinLi commented 3 years ago

Hi @xutting123 ,

The contrastive loss can be computed by the cross-entropy loss. In the formula, by setting labels to 0, x[class] (i.e., x[0]) is the positive pair part.