Last active
June 30, 2021 12:22
-
-
Save sadimanna/d5a827b94e4dc28ad7b1b5473e1ab642 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tdg = DSDataGen('test', testimages, testlabels, num_classes=10) | |
tdl = DataLoader(tdg, batch_size = 32, drop_last = True) | |
dsmodel.eval() | |
loss_sublist = np.array([]) | |
acc_sublist = np.array([]) | |
with torch.no_grad(): | |
for x,y in vdl: | |
x = x.squeeze().to(device = 'cuda:0', dtype = torch.float) | |
y = y.to(device = 'cuda:0') | |
z = dsmodel(x) | |
val_loss = loss_fn(z,y) | |
preds = torch.exp(z.cpu().data)/torch.sum(torch.exp(z.cpu().data)) | |
loss_sublist = np.append(loss_sublist, val_loss.cpu().data) | |
acc_sublist = np.append(acc_sublist,np.array(np.argmax(preds,axis=1)==y.cpu().data.view(-1)).astype('int'),axis=0) | |
print('TEST BINARY CROSSENTROPY LOSS: ',np.mean(loss_sublist)) | |
print('TEST BINARY ACCURACY: ',np.mean(acc_sublist)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment