List<float> doSinglePrediction(){
MXNetInferenceModel model = new MXNetInferenceModel();
model.load("/local/path/to/model");
List<float> singlePrediction = Arrays.asList(3.14159, .5772, 2.71828);
model.predict(singlePrediction);
return model.getPredictions().get(0);
}
List<List<float>> doBatchPrediction(){
MXNetInferenceModel model = new MXNetInferenceModel();
model.load("/local/path/to/model");
List<List<float>> batchPrediction = Arrays.asList(
Arrays.asList(3.14159, .5772, 2.71828),
Arrays.asList(.5772, 2.71828, 3.14159),
Arrays.asList(2.71828, 3.14159, .5772));
model.predict(batchPrediction);
return model.getPredictions();
} |