Inference and GPU Modes

Comprehensive guide to Inference in Linea

ML Inference

Inference runs a trained model without updating weights.

import ml
func predict(model: any, x: any) -> any {
    return model.forward(x)
}

var sample = [[5.8, 2.7, 5.1, 1.9]]
var y = predict(model, sample)
display y

Serving Tip

Wrap preprocessing and postprocessing around inference functions to keep outputs consistent.