l4c trouble in notebook
Closed this issue · 2 comments
Dear colleagues.
The problem of casaid-torch fusion was struggling us for a long time. So we highly appreciate your project and will mention you in our papers, thanks.
The problems:
if run the following code in notebook twice there will be the error:
deep_model = DeepModel(5, 40)
mx_inp = cs.MX.sym('x', deep_model.input_layer.in_features, 1)
l4c.L4CasADi(deep_model, has_batch=True)(mx_inp)
deep_model = DeepModel(10, 40)
mx_inp = cs.MX.sym('x', deep_model.input_layer.in_features, 1)
l4c.L4CasADi(deep_model, has_batch=True)(mx_inp)
Error
File ~/Desktop/Docker/venv/lib/python3.9/site-packages/l4casadi/l4casadi.py:53, in L4CasADi.forward(self, inp)
50 if not self._ready:
51 self.get_ready(inp)
---> 53 out = self._ext_cs_fun(inp) # type: ignore[misc]
55 return out
File ~/Desktop/Docker/venv/lib/python3.9/site-packages/casadi/casadi.py:23339, in Function.call(self, *args, **kwargs)
23336 raise SyntaxError('Function evaluation requires all arguments to be named or none')
23337 if len(args)>0:
23338 # Ordered inputs -> return tuple
23339 ret = self.call(args)
23340 if len(ret)==0:
...
- The input dimension N-by-M (here 10-by-1)
- A scalar, i.e. 1-by-1
- M-by-N if N=1 or M=1 (i.e. a transposed vector)
- N-by-M1 if K*M1=M for some K (argument repeated horizontally)
- N-by-P*M, indicating evaluation with multiple arguments (P must be a multiple of 1 for consistency with previous inputs)
I believe the l4c somehow contains the information about the prev model. but again, it only happens if run it twice in a notebook.
I found several problems when running the l4c.L4CasADi twice in the cell. they all look like l4c capture model inside.
Hi,
I am glad you find the framework helpful. Please try and give the two L4CasADi models unique names. E.g. L4CasADi(model, ..., name='f1')
.
Let me know if this solves the problem. Otherwise, I will look more into it.
Best
Tim
Hi,
Yes, It helped. Thank you so much.