| predict.onnx_model | R Documentation |
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 class 'onnx_model'
predict(object, x, batch_size = NULL, ...)
object |
An |
x |
Input data: an array or matrix whose first dimension indexes samples, or a named list of such arrays for multi-input models. |
batch_size |
Ignored, with a warning if not |
... |
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.
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.
onnx_run for the lower-level named-list interface.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.