我有一个类似于tensorflow语音命令演示的模型,除了它采用可变大小的1D数组作为输入。现在,我发现很难使用tflite_convert将此模型转换为TF lite,这需要input_shape作为输入。
据说tf lite需要固定大小的输入才能提高效率,您可以在推理过程中将输入的大小调整为模型的一部分。但是,我认为这将涉及截断我不需要的输入。有什么方法可以使TF lite起作用吗?
答案 0 :(得分:1)
您可以使用--input_shape=64
中的固定形状来转换模型,然后在推断时执行以下操作:
interpreter->ResizeInputTensor(interpreter->inputs()[0], {128});
interpreter->AllocateTensors();
// ... populate your input tensors with 128 entries ...
interpreter->Invoke();
// ... read your output tensor ...