Metric
Interface for evaluation metrics that accumulate statistics over batches.
Metrics follow a stateful accumulation pattern:
Call update for each batch of predictions/targets
Call compute to get the accumulated metric value
Call reset to start a new evaluation epoch
Example usage:
val accuracy = Accuracy()
for ((x, y) in validationData) {
val preds = model.forward(x, ctx)
accuracy.update(preds, y, ctx)
}
println("Validation accuracy: ${accuracy.compute()}")
accuracy.reset()Content copied to clipboard