lorenmt / reco

The implementation of "Bootstrapping Semantic Segmentation with Regional Contrast" [ICLR 2022].
https://shikun.io/projects/regional-contrast
Other
162 stars 25 forks source link

About the gradient flow in contrastive learning #30

Closed Gavinwxy closed 1 year ago

Gavinwxy commented 1 year ago

I notice that you do not apply detach operation when you do contrastive learning, which means the loss gradient applies on both query and keys. I was wondering if this is a common practice because in other works based on contrastive learning, the gradients only flow through query samples. Does it make any difference on training? Any hints will be appreciated.

lorenmt commented 1 year ago

https://github.com/lorenmt/reco/blob/71c1b7324fd36049c6657b122ba3fef373877b72/module_list.py#L112 No gradients were flowed through keys.

Gavinwxy commented 1 year ago

Thanks for the reply