I’m creating a Pytorch OCR model with a Resnet based feature extractor with both ctc classifier and attention based classifer outputs.
It includes a BiLSTM layer that input from the resnet so I can recognize the text image. I’m trying to use the torchserve which the model need to be torch.jit.trace or torch.jit.script. I’m able to use the torch.jit.trace to create a traced model, however it shows the following errors when the input’s batch size not matching the batch size that being traced.
RuntimeError: self dim 0 must match batch2 dim 0
Then I try to use the torch.jit.script it shows the following error.
276 method = getattr(self, 'build_' + node.__class__.__name__, None)
277 if method is None:
--> 278 raise UnsupportedNodeError(ctx, node)
279 return method(ctx, node)
280
UnsupportedNodeError: GeneratorExp aren't supported:
File "/home/usr/venv/lib/python3.7/site-packages/torch/nn/modules/rnn.py", line 158
# alias would break the assumptions of the uniqueness check in
# Module.named_parameters().
unique_data_ptrs = set(p.data_ptr() for p in self._flat_weights)
~ <--- HERE
if len(unique_data_ptrs) != len(self._flat_weights):
return
How can I solve this problem?