簡體   English   中英

如何在Tensorflow Lite(實驗性C API)中創建輸入張量並與解釋器一起使用?

[英]How to create input tensors and use with interpreter in Tensorflow Lite (experimental C API)?

我們如何使用C API在Tensorflow Lite中創建張量? 然后我們如何在解釋器中使用它們?

我了解Tensorflow Lite擁有有關C ++ API的文檔,而常規Tensorflow擁有有關C API的文檔。 但是,關於使用C API for Lite的信息很少。

Lite C ++ API具有創建張量的功能,但我看不到Lite的C API頭文件(或任何其他相關頭文件/源文件)中的任何位置。

使用常規Tensorflow C API的示例中存在以下內容。 但是它似乎在TF Lite C API中不存在。

TF_Tensor* input_tensor = tf_utils::CreateTensor(TF_FLOAT, input_dims.data(), input_dims.size(), input_vals.data(), input_vals.size() * sizeof(float));

TensorFlow Lite張量( TFL_Tensor )由解釋器( TFL_Interpreter )實例擁有,並且不能由用戶創建。 您可以使用以下方法獲取輸入/輸出張量的句柄:

 TFL_Tensor* TFL_InterpreterGetInputTensor(
    const TFL_Interpreter* interpreter, int32_t input_index);

 const TFL_Tensor* TFL_InterpreterGetOutputTensor(
    const TFL_Interpreter* interpreter, int32_t output_index);

可以使用c_api.h標頭中描述的方法讀取(或更新)張量數據。 缺少文檔,因為它仍然是實驗API,但我們希望在不久的將來將其從實驗中移出。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM