Runs inference over x, batching it to the fixed input shape the
model was loaded with. This is the keras-compatible entry point: together
with the ggml_sequential_model and ggml_functional_model
methods it gives ggmlR and ONNX models a single predict() interface.
# S3 method for onnx_model
predict(object, x, batch_size = NULL, ...)For a single-output model, an array with the model's output
dimensions and nrow(x) samples in the first one (a matrix when the
output is 2D). For a multi-output model, a named list of such arrays.
An onnx_model from onnx_load.
Input data: an array or matrix whose first dimension indexes samples, or a named list of such arrays for multi-input models.
Ignored, with a warning if not NULL. The batch
size is fixed when the model is loaded; pass input_shapes to
onnx_load to change it. The argument exists so the
signature matches the other predict() methods.
Ignored.
Unlike onnx_run, which takes a named list of inputs and always
returns a named list of outputs, this method takes an array (or a named list
for multi-input models) and unwraps a single output. The output keeps the
dimensions the model produced: a 2D output comes back as a matrix, a 4D
output stays 4D.
An ONNX graph is built for one fixed batch size at onnx_load
time and cannot be resized afterwards, so x is split into chunks of
that size. A trailing partial chunk is padded to a full batch and the
padding is dropped from the result.
onnx_run for the lower-level named-list interface.