KunpengLi1994 / VSRN

PyTorch code for ICCV'19 paper "Visual Semantic Reasoning for Image-Text Matching"
288 stars 47 forks source link

train trick some questions #24

Closed Mr-Monday closed 2 years ago

Mr-Monday commented 2 years ago

Hi,I am learning your VSRN code. I have some questions.
When training and testing, does this " self.caption_model = S2VTAttModel(self.encoder, self.decoder) " code need to be changed to self.caption_model.train() and self.caption_model.eval() in def train_start(self) and def val_start(self). as follows

def train_start(self):
    """switch to train mode
    """
    self.img_enc.train()
    self.txt_enc.train()
   self.caption_model.train() 

def val_start(self):
    """switch to evaluate mode
    """
    self.img_enc.eval()
    self.txt_enc.eval()
    self.caption_model.eval()
KunpengLi1994 commented 2 years ago

Hi Thanks for your interest in our work. Since caption_model is only used during training to enhance the visual representation learning and it is not used for testing, it is not necessary to add self.caption_model.eval() to "def val_start(self)". As for training, if I remember correctly, the default setting of the module is .train(), therefore, I think it is also not necessary to add this line to "def train_start(self)".

Mr-Monday commented 2 years ago

Thank you for your reply,I found out later when I was reading the code that The model did not use this module in the test. There is really no need to add this module this line to "def train_start(self)".