Person-reID-triplet-loss icon indicating copy to clipboard operation
Person-reID-triplet-loss copied to clipboard

Why skip last batch?

Open Tiamo666 opened this issue 6 years ago • 6 comments

Hi, Zedong, Thanks a lot for your work. I was a little confused about the following code: if now_batch_size<opt.batchsize: # next epoch continue Does it will influence the performance?

Tiamo666 avatar Oct 11 '18 03:10 Tiamo666

Hi @Tiamo666 Generally, it may not compromise the final performance. But in some cases, it does.

  1. For example, after you have trained most images in the training set, you may left one image. Using batch normalisation, one image will output zero and abnormal prediction.
  2. Small batchsize also will affect the running mean and std in the batchnorm layer.

layumi avatar Oct 11 '18 03:10 layumi

@layumi thanks for your kind explanation, I got it. Another question is that in your implementation of triplet loss, I found that you get the negative hard samples is a little different. your input includes sample, target, pos, pos_target. And you just get hard negative from "pos" exclude sample, I was confused about that.

Tiamo666 avatar Oct 11 '18 04:10 Tiamo666

@Tiamo666 Sure. You can sample another batch as negative pool. But it may be more efficient by directly using other positive data as negative sample.

layumi avatar Oct 11 '18 04:10 layumi

@layumi OK. And is it necessary to do the random permutation of "nf_data"(in train_new.py line ~217)? Cause your default opt.poolsize is 128(equal to the batchsize of nf_data), and after sorting score, the result will be the same.

Tiamo666 avatar Oct 11 '18 05:10 Tiamo666

@Tiamo666 It is designed for the small poolsize. If you using the biggest pool size, it is not necessary.

layumi avatar Oct 11 '18 18:10 layumi

Hi, @layumi Thanks a lot

Tiamo666 avatar Oct 12 '18 05:10 Tiamo666