MCPcopy Create free account
hub / github.com/clab/dynet / IsCurrentPredictionCorrection

Function IsCurrentPredictionCorrection

examples/textcat/train_textcat.cc:150–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148};
149
150bool IsCurrentPredictionCorrection(Expression y_pred, int y_true) {
151 ComputationGraph& cg = *y_pred.pg;
152 auto v = as_vector(cg.incremental_forward(y_pred));
153 assert(v.size() > 1);
154 int besti = 0;
155 float best = v[0];
156 for (unsigned i = 1; i < v.size(); ++i)
157 if (v[i] > best) { best = v[i]; besti = i; }
158 return (besti == y_true);
159}
160
161Expression CrossEntropyLoss(const Expression& y_pred, int y_true) {
162 Expression lp = log_softmax(y_pred);

Callers 1

mainFunction · 0.85

Calls 3

as_vectorFunction · 0.85
incremental_forwardMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected