(model, inputs)
| 111 | # also encapsulate these steps |
| 112 | # Note: inputs is a torch tensor |
| 113 | def predict(model, inputs): |
| 114 | # set the model to testing mode |
| 115 | # because batch norm has 2 different modes! |
| 116 | model.eval() |
| 117 | |
| 118 | inputs = Variable(inputs, requires_grad=False) |
| 119 | logits = model.forward(inputs) |
| 120 | return logits.data.numpy().argmax(axis=1) |
| 121 | |
| 122 | |
| 123 | # return the accuracy |