LMPT icon indicating copy to clipboard operation
LMPT copied to clipboard

Questions about CSE Loss

Open fmy7834 opened this issue 9 months ago • 0 comments

Hello, I 'm interested in your excellent work. And I have two questions when re-produce your work.

  1. In line 210 of lmpt/train.py: class_weights = sfm(torch.from_numpy(np.asarray(mmcv.load(freq_file)['class_freq'])).to(torch.float32).cuda()), Why apply softmax on class_counts? After applying it, the result contains zeros, which influence the calculation of margin and class_weights in csel.py (class_counts is as denominator). For example, for voc-lt, class_counts after softmax is like this:
    image

  2. In line 20 of lmpt/csel.py: self.class_counts = self.class_counts.squeeze(dim=0).expand(labels.shape[0], self.class_counts.shape[-1]), after this line, self.class_counts has two dimensions: [batch_size, n_cls]. But in line 25, it requires self.class_counts to have a third dimension in torch.sum(dim=2): class_weights = (1 / self.class_counts) ** self.gamma / torch.sum((1 / self.class_counts) ** self.gamma, dim=2) I think the line 25 should be like this: class_weights = (1 / self.class_counts) ** self.gamma / torch.sum((1 / self.class_counts) ** self.gamma, dim=1, keepdim=True)

I would appreciate it if you could answer my confusions.

fmy7834 avatar May 03 '24 10:05 fmy7834