【发布时间】:2019-07-06 23:43:27
【问题描述】:
在 PyTorch C++ Frontend api 的帮助下,我编写了一个代码来在 C++ 中加载 pytorch 模型。我想通过使用module->forward(batch_frames) 为 C++ 中的预训练模型提供一批帧。但它可以通过单个输入转发。
如何给模型提供一批输入?
我要给批处理的部分代码如下所示:
cv::Mat frame;
vector<torch::jit::IValue> frame_batch;
// do some pre-processes on each frame and then add it to the frame_batch
//forward through the batch frames
torch::Tensor output = module->forward(frame_batch).toTensor();
【问题讨论】:
-
你有什么解决办法吗?我在discuss.pytorch.org/t/… 也问过同样的问题
-
还没有!我以为问题会通过更新 libtorch 来解决,但什么也没发生。感谢您分享您的问题。 @马库斯
-
我的问题在上面的链接中得到了回答。