如何使用 TensorFlow Lite 进行批处理? [英] How to do batching with TensorFlow Lite?

查看:33
本文介绍了如何使用 TensorFlow Lite 进行批处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义 CNN 模型,我已将其转换为 .tflite 格式并将其部署在我的 Android 应用程序中.但是,我无法弄清楚如何在使用 tensorflow lite 进行推理时进行批处理.

I have a custom CNN model, and I have converted it to .tflite format and deployed it on my Android app. However, I can't figure out how to do batching while inference with tensorflow lite.

从这个 Google doc 看来您必须设置模型的输入格式.但是,本文档使用的是带有 Firebase API 的代码示例,我不打算使用它.

From this Google doc, it seems you have to set the input format of your model. However, this doc is using a code example with Firebase API, which I'm not planning on using.

更具体地说:

我想一次推断多个 100x100x3 图像,因此输入大小为 Nx100x100x3.

I want to inference multiple 100x100x3 images at once, so the input size is Nx100x100x3.

问题:

如何用 TF lite 做到这一点?

How to do this with TF lite?

推荐答案

您只需调用 resizeInput API (Java) 或 ResizeInputTensor API(如果您正在使用C++).

You can just call the resizeInput API (Java) or ResizeInputTensor API (if you're using C++).

例如,在 Java 中:

For example, in Java:

interpreter.resizeInput(tensor_index, [num_batch, 100, 100, 3]);

如果您在 TensorFlow lite 中遇到批处理问题,请告诉我们.

Let us know if you have any problem batching in TensorFlow lite.

这篇关于如何使用 TensorFlow Lite 进行批处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆