TL;DR
I encountered some errors while using the EKF filtering for performing BIP inference both from my code and from the minimal.py example that is provided. The corresponding fixes can be seen in the commit: souljaboy764/intprim@4ab692c
Long Version:
I was trying to use the EKF filter for performing the performing inference with the BIP, but was getting the following error:
File "build/bdist.linux-x86_64/egg/intprim/bayesian_interaction_primitives.py", line 298, in generate_probable_trajectory_recursive
File "build/bdist.linux-x86_64/egg/intprim/filter/spatiotemporal/ekf.py", line 157, in localize
File "build/bdist.linux-x86_64/egg/intprim/filter/spatiotemporal/nonlinear_system.py", line 109, in get_measurement_model
File "build/bdist.linux-x86_64/egg/intprim/basis/basis_model.py", line 91, in get_weighted_vector_derivative
IndexError: invalid index to scalar variable.
I thought it might have been an issue in my code but I was getting this issue even when I was running minimal.py with the EKF filter. I am getting the issue in both python2 and python3.
The stack trace shows the error in basis_model.py in the get_weighted_vector_derivative function at the following line:
|
basis_func_derivs = self.get_basis_function_derivatives(x[0]) |
On reading the docstring of the function, it says:that x should be a scalar value:
|
# @param x Scalar containing the phase value to use in the creation of the block diagonal matrix. |
I am able to resolve this issue with dropping the index used for x and the line now looks like:
basis_func_derivs = self.get_basis_function_derivatives(x)
After fixing the above, I get the next error:
File "build/bdist.linux-x86_64/egg/intprim/bayesian_interaction_primitives.py", line 298, in generate_probable_trajectory_recursive
File "build/bdist.linux-x86_64/egg/intprim/filter/spatiotemporal/ekf.py", line 157, in localize
File "build/bdist.linux-x86_64/egg/intprim/filter/spatiotemporal/nonlinear_system.py", line 110, in get_measurement_model
File "build/bdist.linux-x86_64/egg/intprim/basis/basis_model.py", line 50, in get_block_diagonal_basis_matrix
ValueError: could not broadcast input array from shape (8) into shape (8,1)
On looking further, I saw that the phase value x passed to the get_block_diagonal_basis_matrix function in basis_model.py is a scalar value, which is used here:
|
basis_funcs = self.get_basis_functions(x) |
The docstrings of the get_basis_functions function for all the different basis functions state that the shape of the return value would be shape(degree, ) if x is a scalar. so I am able to fix this by expanding the dimensions of the value returned by the function:
basis_funcs = self.get_basis_functions(x)
if np.isscalar(x):
basis_funcs = basis_funcs[:, None]
Since this is the same case in the get_block_diagonal_basis_matrix_derivative function, I felt a similar change there would fit.
The next error I get is:
File "build/bdist.linux-x86_64/egg/intprim/bayesian_interaction_primitives.py", line 298, in generate_probable_trajectory_recursive
File "build/bdist.linux-x86_64/egg/intprim/filter/spatiotemporal/ekf.py", line 157, in localize
AttributeError: 'GaussianModel' object has no attribute 'inverse_transform'
which is basically this line:
|
predicted_measurement = np.dot(measurement_model[:,self.system_size:], self.basis_model.inverse_transform(self.state_mean[self.system_size:])) |
After digging further, I saw that the only use of inverse_transform is for the scalers and not for any basis functions. Maybe it is from a previous version? I changed that part of the code to how it is in kf.py:
predicted_measurement = np.dot(measurement_model[:,self.system_size:], self.state_mean[self.system_size:])
TL;DR
I encountered some errors while using the EKF filtering for performing BIP inference both from my code and from the
minimal.pyexample that is provided. The corresponding fixes can be seen in the commit: souljaboy764/intprim@4ab692cLong Version:
I was trying to use the EKF filter for performing the performing inference with the BIP, but was getting the following error:
I thought it might have been an issue in my code but I was getting this issue even when I was running
minimal.pywith the EKF filter. I am getting the issue in both python2 and python3.The stack trace shows the error in
basis_model.pyin theget_weighted_vector_derivativefunction at the following line:intprim/intprim/basis/basis_model.py
Line 91 in 8994b15
On reading the docstring of the function, it says:that
xshould be a scalar value:intprim/intprim/basis/basis_model.py
Line 78 in 8994b15
I am able to resolve this issue with dropping the index used for
xand the line now looks like:After fixing the above, I get the next error:
On looking further, I saw that the phase value
xpassed to theget_block_diagonal_basis_matrixfunction inbasis_model.pyis a scalar value, which is used here:intprim/intprim/basis/basis_model.py
Line 48 in 8994b15
The docstrings of the
get_basis_functionsfunction for all the different basis functions state that the shape of the return value would beshape(degree, ) if x is a scalar.so I am able to fix this by expanding the dimensions of the value returned by the function:Since this is the same case in the
get_block_diagonal_basis_matrix_derivativefunction, I felt a similar change there would fit.The next error I get is:
which is basically this line:
intprim/intprim/filter/spatiotemporal/ekf.py
Line 157 in 8994b15
After digging further, I saw that the only use of
inverse_transformis for the scalers and not for any basis functions. Maybe it is from a previous version? I changed that part of the code to how it is inkf.py: