I have trained a neural network (NN) model in PyTorch that represents the dynamics of my system. Now, I am trying to create an L4CasADi model from the PyTorch model in order to implement model predictive control (MPC) with CasADi, following the article and : the code available on GitHub. Here is my code:
import l4casadi as l4c
checkpoint = torch.load(
"/content/pytorch_palie5_model.pt",
map_location=torch.device('cpu'),
)
# Standardization
model = checkpoint["model"]
meanX = checkpoint["mean"]["x"]
stdX = checkpoint["std"]["x"]
meanY = checkpoint["mean"]["y"]
stdY = checkpoint["std"]["y"]
print(model)
print(meanX)
print(stdX)
print(meanY)
print(stdY)
x = cs.MX.sym("x", 3)
xn = (x - meanX) / stdX
print(x.shape)
print(xn.shape)
#create casadi model
y = l4c.L4CasADi(model)(xn)
However, I am encountering an error that I cannot resolve.
0