如何在android上设置tflite模型的输入张量和输出张量?

2024-04-29 08:48:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个型号:

input shape: (batch_size, 3, 48, 64, 18)
output shape: (batch_size, 512)

我想把这个模型转换成tflite模型,并在android上运行。在

tflite的官方示例显示输入张量是one-dimensional ByteBuffer,输出张量是浮点数组。在

如何将带有形状(批次大小,3,48,64,18)的输入数据存储到ByteBuffer?在

在我的项目中,我设置了batch_size = 3,因为原始输入数据的形状是(54,48,64,18),我使用numpy.reshape将数据重塑为(3,3,48,64,18)。在

真的需要先做整形吗?在

我可以直接将形状(54,48,64,18)的数据存储到ByteBuffer吗?在


Tags: 数据模型示例inputoutputsize官方batch