MCPcopy Index your code
hub / github.com/lazyprogrammer/machine_learning_examples / get_cost

Function get_cost

ann_class2/pytorch_dropout.py:96–108  ·  view source on GitHub ↗
(model, loss, inputs, labels)

Source from the content-addressed store, hash-verified

94
95# similar to train() but not doing the backprop step
96def get_cost(model, loss, inputs, labels):
97 # set the model to testing mode
98 # because dropout has 2 different modes!
99 model.eval()
100
101 inputs = Variable(inputs, requires_grad=False)
102 labels = Variable(labels, requires_grad=False)
103
104 # Forward
105 logits = model.forward(inputs)
106 output = loss.forward(logits, labels)
107
108 return output.item()
109
110
111# define the prediction procedure

Callers 1

pytorch_dropout.pyFile · 0.70

Calls 1

forwardMethod · 0.45

Tested by

no test coverage detected