You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
with torch.no_grad():
for i, (teeg, tlabel) in enumerate(self.test_dataloader):
teeg = Variable(teeg.type(self.Tensor))
tlabel = Variable(tlabel.type(self.LongTensor))
all_center = Variable(all_center.type(self.Tensor))
tfea = self.Proj_eeg(self.Enc_eeg(teeg))
tfea = tfea / tfea.norm(dim=1, keepdim=True)
similarity = (100.0 * tfea @ all_center.t()).softmax(dim=-1) # no use 100?
_, indices = similarity.topk(5)
tt_label = tlabel.view(-1, 1)
total += tlabel.size(0)
top1 += (tt_label == indices[:, :1]).sum().item()
top3 += (tt_label == indices[:, :3]).sum().item()
top5 += (tt_label == indices).sum().item()
Hello. I have a question while referencing your code. I saw the code for obtaining top1,3,5 accuracy in nice_stand.py, and I understand that t_label represents the actual integer label of the data. Then, after taking the inner product of eeg and image embedding, it is expressed as a probability distribution through softmax, and then the top k with the highest probability are selected and indices, which are the index information of these, are obtained. t_label is expressed as tt_label by converting the shape and then selecting k indices in order according to the highest probability according to k = 1, 3, 5 and then comparing them with tt_label. The problem here is that tt_label represents the actual integer label of the corresponding data, and indices represent the index information of the position with the highest probability, but the two values are not comparable, so how can the top-1,3,5 accuracy be obtained?
The text was updated successfully, but these errors were encountered:
Hello. I have a question while referencing your code. I saw the code for obtaining top1,3,5 accuracy in nice_stand.py, and I understand that t_label represents the actual integer label of the data. Then, after taking the inner product of eeg and image embedding, it is expressed as a probability distribution through softmax, and then the top k with the highest probability are selected and indices, which are the index information of these, are obtained. t_label is expressed as tt_label by converting the shape and then selecting k indices in order according to the highest probability according to k = 1, 3, 5 and then comparing them with tt_label. The problem here is that tt_label represents the actual integer label of the corresponding data, and indices represent the index information of the position with the highest probability, but the two values are not comparable, so how can the top-1,3,5 accuracy be obtained?
The text was updated successfully, but these errors were encountered: