공개 최종 클래스
통역사
TensorFlow Lite로 모델 추론을 구동하는 드라이버 클래스입니다.
참고: 아래 API 기능에 대한 자세한 내용은 InterpreterApi와 InterpreterFactory의 인스턴스를 만듭니다.
Interpreter
는 선행 학습된 TensorFlow Lite 모델을 캡슐화합니다. 이 모델에서 연산은
모델 추론을 위해 실행됩니다
예를 들어 모델이 하나의 입력만 취하고 하나의 출력만 반환하는 경우:
try (Interpreter interpreter = new Interpreter(file_of_a_tensorflowlite_model)) {
interpreter.run(input, output);
}
모델이 여러 입력 또는 출력을 사용하는 경우:
Object[] inputs = {input0, input1, ...};
Map<Integer, Object> map_of_indices_to_outputs = new HashMap<>();
FloatBuffer ith_output = FloatBuffer.allocateDirect(3 * 2 * 4); // Float tensor, shape 3x2x4.
ith_output.order(ByteOrder.nativeOrder());
map_of_indices_to_outputs.put(i, ith_output);
try (Interpreter interpreter = new Interpreter(file_of_a_tensorflowlite_model)) {
interpreter.runForMultipleInputsOutputs(inputs, map_of_indices_to_outputs);
}
모델이 문자열 텐서를 취하거나 생성하는 경우:
String[] input = {"foo", "bar"}; // Input tensor shape is [2].
String[][] output = new String[3