OFA-Sys / Chinese-CLIP

Chinese version of CLIP which achieves Chinese cross-modal retrieval and representation generation.
MIT License
4.32k stars 448 forks source link

Question: gradient accumulate #326

Open zwhus opened 2 months ago

zwhus commented 2 months ago

Thanks for your work! I have a question about gradient accumulate on contrastive learning. you use the code as follows:

all_teacher_image_features = torch.cat(
      [teacher_image_features]
      + gathered_teacher_image_features[:rank]
      + gathered_teacher_image_features[rank + 1 :]
  )

why not use the code

gathered_teacher_image_features[self.rank] = teacher_image_features
all_teacher_image_features = torch.cat(gathered_teacher_image_features, dim=0)