(model, loss, inputs, labels)
| 87 | |
| 88 | # similar to train() but not doing the backprop step |
| 89 | def get_cost(model, loss, inputs, labels): |
| 90 | inputs = Variable(inputs, requires_grad=False) |
| 91 | labels = Variable(labels, requires_grad=False) |
| 92 | |
| 93 | # Forward |
| 94 | logits = model.forward(inputs) |
| 95 | output = loss.forward(logits, labels) |
| 96 | |
| 97 | return output.item() |
| 98 | |
| 99 | |
| 100 | # define the prediction procedure |
no test coverage detected