I want to convert python model to pytorch lite, but I got above error.
TracerWarning: Converting a tensor to a Python integer might cause the trace to be incorrect. We can’t record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
My code is simple,
class CNN_forward(torch.nn.Module):
def __init__(self):
super(CNN_forward, self).__init__()
self.cnn= nn.Sequential(*list(models.mobilenet_v3_small(pretrained=True).children())[0])
def forward(self, pixel):
raw_data = pixel.transpose(1, 2)
pixel= torch.squeeze(pixel, 0)
preproc_data = self.batch(pixel)
return preproc_data
I have to change axis of 1 and 2 because my java code generate tensor as
[1 x RGB x Num frames x H x W] so it can not pass CNN
so i changed to [1 x Num Frames x RGB x H x W]
In my case Num Frames is only 1
But They say some warnning.
Shold I change my python model?
Also, After run on mobile, I got this error, as same as below
Mobile optimized model raised error “required rank 4 tensor to use channels_last format”
What is this error comes from?
There is no batch size if run on mobile?
OR when num frames is one, there dimemsion is deleted on mobile?
Thx