Re-create Figure 6 in "Safe Learning in Robotics" errors
jwangjie opened this issue ยท 15 comments
Hey Jacopo,
Thanks for the great review paper and open sourcing the accompanying codes here.
I would like to reproduce Figure 6 by following commands but got error messages after successfully loading five GP models as
#########################################
# Loading GP dimension 5 #
#########################################
Path: ./trained_gp_model/best_model_5.pth
Loaded!
Traceback (most recent call last):
File "./gp_mpc_experiment.py", line 179, in <module>
ctrl.learn()
File "/home/jwang/Control_ws/src/safe-control-gym/safe_control_gym/controllers/mpc/gp_mpc.py", line 809, in learn
self.reset()
File "/home/jwang/Control_ws/src/safe-control-gym/safe_control_gym/controllers/mpc/gp_mpc.py", line 899, in reset
self.setup_gp_optimizer(n_ind_points)
File "/home/jwang/Control_ws/src/safe-control-gym/safe_control_gym/controllers/mpc/gp_mpc.py", line 562, in setup_gp_optimizer
mean_post_factor_val, Sigma, K_zind_zind_inv, z_ind_val = self.precompute_sparse_gp_values(n_ind_points)
File "/home/jwang/Control_ws/src/safe-control-gym/safe_control_gym/controllers/mpc/gp_mpc.py", line 394, in precompute_sparse_gp_values
inds, dist_mat = pairwise_distances_argmin_min(centroids, inputs[:, self.input_mask])
File "/home/jwang/anaconda3/envs/safe/lib/python3.8/site-packages/sklearn/metrics/pairwise.py", line 680, in pairwise_distances_argmin_min
values, indices = PairwiseDistancesArgKmin.compute(
File "sklearn/metrics/_pairwise_distances_reduction.pyx", line 672, in sklearn.metrics._pairwise_distances_reduction.PairwiseDistancesArgKmin.compute
File "sklearn/metrics/_pairwise_distances_reduction.pyx", line 1055, in sklearn.metrics._pairwise_distances_reduction.FastEuclideanPairwiseDistancesArgKmin.__init__
File "sklearn/metrics/_dist_metrics.pyx", line 1300, in sklearn.metrics._dist_metrics.DatasetsPair.get_for
File "sklearn/metrics/_dist_metrics.pyx", line 1349, in sklearn.metrics._dist_metrics.DenseDenseDatasetsPair.__init__
File "stringsource", line 658, in View.MemoryView.memoryview_cwrapper
File "stringsource", line 349, in View.MemoryView.memoryview.__cinit__
ValueError: ndarray is not C-contiguous
I wonder if you could help with this? Thank you.
Regards,
Jie
Hi Jie,
Yes, I believe this is an issue with the sklearn and python version you might be using. Are you using python 3.8.10?
Best,
Adam
Hi Jie,
Yes, I believe this is an issue with the sklearn and python version you might be using. Are you using python 3.8.10?
Best,
Adam
Hi Adam,
Thank for the quick reply. Yes, I use python 3.8.10
in a conda
environment following these commands. It indeed looks like a version compatibility issue, I wonder if there is any quick fix to it? Or how you guys avoided this issue when creating Figure 6 in the review paper. Thanks. //Jie
Okay, interesting. Yes, there is a versioning issue somewhere. What versions of scikit-learn
and 'scikit-optimize' were installed and are running for you?
They both were auto-configured in the conda
environment at ./anaconda3/envs/safe
:
scikit-learn 1.1.1 pypi_0 pypi
scikit-optimize 0.9.0 pypi_0 pypi
@JacopoPan yes I thought so as well. @jwangjie also maybe try changing the scikit-learn
version to 1.0.2. This is what I have running, and it works well.
You can use the command
pip3 install -Iv scikit-learn==1.0.2
@adamhall I re-installed scikit-learn==1.0.2
in conda
and it works. Thanks for the quick help!
@JacopoPan I retrained the models, but the existing modes also didn't work. I work on ubuntu 20.04.4
. I believe the issue is due to scikit-learn
version.
Thanks again for the responsive help, I appreciate it!
Glad it's working for you. Just for our debugging and to be clear, do the plots look reasonable when you run it with both the existing models and the retrained models?
The issue isn't actually in the loading or the training of the models. The function in question is used when selecting inducing points for the GP to keep the size of the GP smaller but still yield reasonable predictions.
It's not ideal to have a dependency stuck on an older version of scikit-learn
, can you either see if this can be addressed in 1.1.1 or create a PR from a fork of main
that removes setup.py
and updates pyproject.toml
accordingly (scikit-learn is installed as dependency of scikit-optimize)?
@JacopoPan Sure, I will first look into seeing what the changes were in the newer version of scikit-learn
and if we can change this function.
Another question not directly related to Figure 6 in the review paper. In safe-control-gym/experiments/arxiv/
, there are arXiv GP-MPC experiment
scripts, I wonder which arxiv paper this is referring to? Thanks.
https://arxiv.org/abs/2109.06325 (it is now officially an IROS/RA-L paper)