Hello Sina!



 sinaabdollahi:

How can I find accuracy and error for test set?


The conventional way to calculate the accuracy:
y_hat_test = model (inputs_test)
dummy, preds_test = torch.max (y_hat_test, dim = 1)
accuracy_test = (preds_test == labels_test).long().sum().float() /  preds_test.size()[0]

That is, you need to convert the raw scores (logits) for each
class output by your model into predictions for a single, specific
class.  Usually you just use the class with the largest logit as
the prediction.
(In newer versions of pytorch you can use the torch.argmax()
function, preds_test = torch.argmax (y_hat_test, dim = 1)
(and dispense with the explicit conversion to .long() before the
.sum()).
I’m not sure what you mean by test-set error.  If you mean your loss
function,you calculate it the same way you would for a training batch
(but wrap it in a volatile = True Variable, or, with newer versions,
use with torch.no_grad():).
Note, you do not want softmax() as the final layer of your model.
I’ve edited my previous post to clarify this.
Good luck.
K. Frank