I trained a PyTorch model following the documentation. The model takes input with dimensions (batch, seq, feature), where seq = 10 and feature = 3, to predict the next output. I saved the model, and now that I’m trying to import it and build the L4CasADi model from the PyTorch model using “Create L4CasADi Model from PyTorch Model,as showing in my code :
model = torch.load(
"/content/pytorch_model_complete.pt",
map_location=torch.device('cpu'),
)
import casadi as cs
import l4casadi as l4c
l4casadi_model = l4c.L4CasADi(
model,
device = 'cpu',
)
tensor = cs.MX.sym("tensor", 1, 10, 3)
y = l4c.L4CasADi(model)(tensor)
I’m encountering the following error: