is_correct = [] predicted_class = [] original_class = [] for i in tqdm(range(0, test_pos.shape[0], batch_size)): if i+batch_size>=test_pos.shape[0]: break #getting batch test_pos_batch = test_pos[i:i+batch_size] test_tok_batch = test_tok[i:i+batch_size] test_targ_batch = test_targ[i:i+batch_size] #making prediction, not masking anything clsf_logits, _ = model(test_tok_batch, test_pos_batch, torch.zeros(test_pos_batch.shape)) #converting logits to probabilities then rounding to classifications res = torch.sigmoid(clsf_logits).round().squeeze() #keeping track of the original class (positive or negative) and if the model was correct original_class.extend(np.array(test_targ_batch.to('cpu'))) is_correct.extend(np.array((res == test_targ_batch).to('cpu'))) predicted_class.extend(np.array(res.detach().to('cpu'))) #accuracy sum(list(is_correct))/len(is_correct)