I
- the type of the inputO
- the type of the outputpublic class BasePredictor<I,O> extends java.lang.Object implements Predictor<I,O>
BasePredictor
contains common code for implementations of the Predictor
interface.Modifier and Type | Field and Description |
---|---|
protected NDManager |
manager |
protected Model |
model |
Constructor and Description |
---|
BasePredictor(Model model,
Translator<I,O> translator,
boolean copy)
|
Modifier and Type | Method and Description |
---|---|
java.util.List<O> |
batchPredict(java.util.List<I> inputs)
Predicts a batch for inference.
|
void |
close() |
protected NDList |
forward(NDList ndList) |
O |
predict(I input)
Predicts an item for inference.
|
void |
setMetrics(Metrics metrics)
Attaches a Metrics param to use for benchmark.
|
protected void |
waitToRead(NDList list) |
public BasePredictor(Model model, Translator<I,O> translator, boolean copy)
model
- the model on which the predictions are basedtranslator
- the translator to be usedcopy
- whether to copy the parameters to the parameter storepublic O predict(I input) throws TranslateException
predict
in interface Predictor<I,O>
input
- the inputTranslateException
- if an error occurs during predictionpublic java.util.List<O> batchPredict(java.util.List<I> inputs) throws TranslateException
batchPredict
in interface Predictor<I,O>
inputs
- a list of inputsTranslateException
- if an error occurs during predictionpublic void setMetrics(Metrics metrics)
setMetrics
in interface Predictor<I,O>
metrics
- the Metrics classprotected void waitToRead(NDList list)