Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-create Figure 6 in "Safe Learning in Robotics" errors #42

Closed
jwangjie opened this issue Jul 13, 2022 · 15 comments
Closed

Re-create Figure 6 in "Safe Learning in Robotics" errors #42

jwangjie opened this issue Jul 13, 2022 · 15 comments
Labels
bug Something isn't working

Comments

@jwangjie
Copy link

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

@adamhall
Copy link
Contributor

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

@jwangjie
Copy link
Author

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

@adamhall
Copy link
Contributor

Okay, interesting. Yes, there is a versioning issue somewhere. What versions of scikit-learn and 'scikit-optimize' were installed and are running for you?

@jwangjie
Copy link
Author

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 JacopoPan added the bug Something isn't working label Jul 13, 2022
@JacopoPan
Copy link
Member

thank for pointing this out @jwangjie and @adamhall for helping with the debugging.
I thought we had encountered and solved this problem before, as soon as we find a fix will patch this.

Also, are you using the models in the repo or newly created ones? Ubuntu or macOS?

@adamhall
Copy link
Contributor

@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.

@adamhall
Copy link
Contributor

You can use the command
pip3 install -Iv scikit-learn==1.0.2

@jwangjie
Copy link
Author

@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!

@adamhall
Copy link
Contributor

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.

@JacopoPan
Copy link
Member

@adamhall

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)?

@adamhall
Copy link
Contributor

@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.

@jwangjie
Copy link
Author

@adamhall The plot looks pretty much the same as this one with both the existing and retrained models.

@jwangjie
Copy link
Author

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.

@JacopoPan
Copy link
Member

https://arxiv.org/abs/2109.06325 (it is now officially an IROS/RA-L paper)

@JacopoPan
Copy link
Member

I'll deem this solved for @jwangjie and PR #46 will address it for all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants