tfzhou / ContrastiveSeg

ICCV2021 (Oral) - Exploring Cross-Image Pixel Contrast for Semantic Segmentation
MIT License
668 stars 88 forks source link

The L2 normalization of features #52

Closed ccccly closed 2 years ago

ccccly commented 2 years ago

Dear author,

I read the code and found that all the embeddings in the loss function are L2-normalized in the projection head, but regarding the dequeue_and_enqueue function, why are the features normalized again at L122 and L134 in trainer_contrastive.py?

tfzhou commented 2 years ago

Hi @ccccly, the normalization in L122 is essential since new features are obtained for segments that are not guaranteed to be normalized. The one in L134 is indeed redundant. I wrote this to keep the code more consistent, but anyway it will have no effect. Feel free to remove it.

ccccly commented 2 years ago

Thx! @tfzhou, I got it now.