DLR: Compact Runtime for Machine Learning Models
dlr.
DLRModel
(**kwargs)¶get_input
(name, shape=None)¶Get the current value of an input.
name (str) – The name of an input
shape (np.array (optional)) – If given, use as the shape of the returned array. Otherwise, the shape of the returned array will be inferred from the last call to set_input().
get_input_dtype
(index)¶Get the type of the input at the given index.
get_input_name
(index)¶Get the name of the input at the given index.
get_output_dtype
(index)¶Get the type of the output at the given index.
get_output_name
(index)¶Get the name of the output at the given index. Only valid when the model has a metadata file.
get_output_names
()¶Get all output names. Only valid when the model has a metadata file.
names
list of str
get_version
()¶Get version of loaded DLR library.
version
str “{major}.{minor}.{patch}”
has_metadata
()¶Whether the model has a metadata file which provides additional information such as output names.
has_metadata
run
(input_values)¶Run inference with given input(s)
input_values (a single numpy.ndarray
or a dictionary) –
For decision tree models, provide a single numpy.ndarray
to indicate a single input, as decision trees always accept only one
input.
For deep learning models, provide a dictionary where keys are input
names (of type str
) and values are input tensors (of type
numpy.ndarray
). Deep learning models allow more than one
input, so each input must have a unique name.
out – Prediction result