What is the Problem with the CASADI examples for callbacks?

124 Views Asked by At

I am currently trying to implement a CasADi callback function into my code but ran into some problems.

While trying to find a solution I tried out the examples that are provided on the CasADi website.
But all of the exemplary code files throw errors when I run them. I also tried different IDEs - same problem.

The error message I am getting when running the code from the file "ocp.py" (can be found here: https://web.casadi.org/blog/tensorflow/) is similar to the one I get when running the other examples.

The error message is the following:

2023-06-30 16:25:27.303202: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
Traceback (most recent call last):
  File "/Users/MyName/Downloads/ocp.py", line 116, in <module>
    model = gpflow.models.GPR(data, value, gpflow.kernels.Constant(nd) + gpflow.kernels.Linear(nd) + gpflow.kernels.White(nd) + gpflow.kernels.RBF(nd))
  File "/Users/MyName/opt/anaconda3/envs/Code/lib/python3.10/site-packages/check_shapes/integration/tf.py", line 76, in wrapped_method
    return wrapped_function(self, *args, **kwargs)
  File "/Users/MyName/opt/anaconda3/envs/Code/lib/python3.10/site-packages/check_shapes/decorator.py", line 182, in wrapped_function
    _check_specs(pre_specs)
  File "/Users/MyName/opt/anaconda3/envs/Code/lib/python3.10/site-packages/check_shapes/decorator.py", line 180, in _check_specs
    checker.check_shapes(processed_specs)
  File "/Users/MyName/opt/anaconda3/envs/Code/lib/python3.10/site-packages/check_shapes/checker.py", line 311, in check_shapes
    dim_checks = self._match_dims(shape_check)
  File "/Users/MyName/opt/anaconda3/envs/Code/lib/python3.10/site-packages/check_shapes/checker.py", line 472, in _match_dims
    self._assert(unallocated_len == 0)
  File "/Users/MyName/opt/anaconda3/envs/Code/lib/python3.10/site-packages/check_shapes/checker.py", line 605, in _assert
    raise ShapeMismatchError(ParallelContext(tuple(contexts)))
check_shapes.exceptions.ShapeMismatchError: 
Tensor shape mismatch.
  Function: GPR_deprecated.__init__
    Declared: /Users/MyName/opt/anaconda3/envs/Code/lib/python3.10/site-packages/gpflow/models/gpr.py:59
    Argument: data
      Index: [0]
        Expected: [N, D]
        Actual:   [21]
      Index: [1]
        Expected: [N, P]
        Actual:   [21]
    Argument: noise_variance
      Expected: []
      Actual:   <Tensor is None or has unknown shape>

Does someone have the same problem?

0

There are 0 best solutions below