tom:

The first enforces the 1/4-3/4 weighting even if the batch sizes are not in that ratio. If the criterion self.crit takes the mean over batch size, this would be identical if the batch size is 3 duts inputs to 9 flick inputs.


Ok, that’s really the answer I want, thank you.
In fact, there are three samples of A datasets (self.tr_dutsloader) and nine samples of B dataset (self.tr_flickrloader) in a batch.
For both codes, the progress of the weght update is identical, but the forward propagation is different(BatchNorm in  self.net(flickr_inputs) and  in self.net(duts_inputs) are different). Do you think I get it right?