alpha_mix_active_learning icon indicating copy to clipboard operation
alpha_mix_active_learning copied to clipboard

Code issues in strategy alpha_mix_sampling.py

Open TTToby opened this issue 1 year ago • 1 comments

Dear author, On line 23 in alpha_mix_sampling.py ulb_probs, org_ulb_embedding = self.predict_prob_embed(self.X[idxs_unlabeled], self.Y[idxs_unlabeled]) By default, we can obtain labels for unlabeled data in the code, but in reality, we should not be able to obtain them. Why can it be written like this here? Looking forward to your answer.

TTToby avatar Apr 14 '23 08:04 TTToby

    def predict_prob_embed(self, X, Y, eval=True):
        loader_te = DataLoader(self.handler(X, Y, transform=self.args['test_transform']),
                               shuffle=False, **self.args['loader_te_args'])

        probs = torch.zeros([len(Y), self.clf.n_label])
        embeddings = torch.zeros([len(Y), self.clf.get_embedding_dim()])
        if eval:
            self.clf.eval()
            with torch.no_grad():
                for x, y, idxs in loader_te:
                    x, y = x.to(self.device), y.to(self.device)
                    out, e1 = self.clf(x)                             
                    prob = F.softmax(out, dim=1)
                    probs[idxs] = prob.cpu()
                    embeddings[idxs] = e1.cpu()
        else:
            self.clf.train()
            for x, y, idxs in loader_te:
                x, y = x.to(self.device), y.to(self.device)
                out, e1 = self.clf(x)
                prob = F.softmax(out, dim=1)
                probs[idxs] = prob.cpu()
                embeddings[idxs] = e1.cpu()

        return probs, embeddings

Y's are garbage arguments. They are not actually used within that function.

In any other case, labels of the unlabeled samples could be probably used for automating the human-in-the-loop during the experiments - and thus validate the whole AL-scheme using a labeled dataset.

pasquale90 avatar Jun 16 '23 13:06 pasquale90