如何将pytorch(CNN+LSTM)模型转换为tflite?

2024-06-25 07:05:50 发布

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

我正在尝试转换以下博客Image Captioning using Deep Learning (CNN and LSTM)中提到的CNN+LSTM模型。相关github回购协议为:Pytorch image captioning

我想把这个pytorch模型转换成tflite。它同时具有编码器和解码器检查点。据我所知,它们都必须转换为tflite(如果我错了,请纠正我)

方法:使用onnx2keras库中提到的示例,onnx2keras我能够将编码器转换为tflite。但对于解码器,我面临以下问题

不确定什么是正确的方法。有谁能建议更好的方法并帮助我实现tflite模型吗

File “convert_pytorch_tf.py”, line 63, in change_ordering=False) File “/root/anaconda3/envs/pyt2tf/lib/python3.7/site-packages/pytorch2keras/converter.py”, line 53, in pytorch_to_keras dummy_output = model(*args) File “/root/anaconda3/envs/pyt2tf/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 550, in call result = self.forward(*input, **kwargs) TypeError: forward() missing 2 required positional arguments: ‘captions’ and ‘lengths’

请告诉我要采用哪种方法,并帮助我解决与我所采用的方法相关的问题


Tags: and方法inpy模型linerootpytorch