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

Function get_cost

ann_class2/pytorch_example2.py:89–97  ·  view source on GitHub ↗
(model, loss, inputs, labels)

Source from the content-addressed store, hash-verified

87
88# similar to train() but not doing the backprop step
89def 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

Callers 1

Calls 1

forwardMethod · 0.45

Tested by

no test coverage detected