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