Hello,
I want to migrate my training scripts from v0.4 to preview v1.0. And I also want to try to load a pytorch model in C++ via torch script.
In my network definition part, there is one operation for splicing the specific number of preceding and following features.
spliced_feats = torch.cat([feats[:,i:sequence_length-self.context[-1]+i,:] for i in self.context], dim=2)
I just follow the instructions in LOADING A PYTORCH MODEL IN C++.
After chaing my code and rerun the training scripts, I got the following errors.
torch.jit.frontend.UnsupportedNodeError: ListComp aren’t supported
@torch.jit.script_method
def forward(self, feats, embeddings=False):
sequence_length = feats.size()[1]
spliced_feats = torch.cat([feats[:,i:sequence_length-self.context[-1]+i,:] for i in self.context], dim=2)
~ <— HERE
out = self.affine(spliced_feats)
if embeddings:
return out
out = F.dropout(out, p=0.2, training=self.training)
…
(Note: some output has been ignored.)
Is this normal? Should I just abandon the usage of list comprehension for solving this problem?
Any help would be highly appreciated, thanks.