공개 인터페이스
InterpreterApi
알려진 간접 하위 클래스 |
TensorFlow Lite 모델 인터프리터 인터페이스(실험적 메서드 제외)
InterpreterApi
인스턴스는 선행 학습된 TensorFlow Lite 모델을 캡슐화합니다. 이 모델은
모델 추론을 위해 실행됩니다
예를 들어 모델이 하나의 입력만 취하고 하나의 출력만 반환하는 경우:
try (InterpreterApi interpreter =
new InterpreterApi.create(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 (InterpreterApi interpreter =
new InterpreterApi.create(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][2]; // Output tensor shape is [3, 2].
try (InterpreterApi interpreter =
new InterpreterApi.create(file_of_a_tensorflowlite_model)) {
interpreter.runForMultipleInputsOutputs(input, output