Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

ValueError in qp_solver.py #1334

Closed
Supers25 opened this issue Oct 12, 2020 · 11 comments · Fixed by #1378
Closed

ValueError in qp_solver.py #1334

Supers25 opened this issue Oct 12, 2020 · 11 comments · Fixed by #1378
Assignees
Labels
type: bug Something isn't working

Comments

@Supers25
Copy link

I have been trying to train a qsvm with my own dataset. But It returns this ValueError from qp_slover.py
ValueError: cannot reshape array of size 1 into shape (1614,1)
I have tried to run the model with different feature_maps, but the problem persists. Would you please tell me what the issue could be and how to solve it?

@woodsp-ibm
Copy link
Member

This has been noticed recently that with some sizes of data the optimization that is done in qp_solver can fail and that is the result. We are thinking of adding some additional regularization term that allows the optimization a better chance of success. It has worked for the data sets and sizes we tried. Until that is added my only suggestion would be to try a different size for a your data set - for instance we saw cases where 42 would work, 43 would fail as above, and 44 would work.

@Supers25
Copy link
Author

Thank you for your quick reply. I will try that.

@Supers25
Copy link
Author

@woodsp-ibm I have tried different dataset sizes, but none of them worked. Is there anything else I could do? Should I do something different if the dataset is nonlinear separable?

@woodsp-ibm
Copy link
Member

I mentioned that we were thinking of adding an additional regularization term which solves the problem on the data sets that we have tried. It would mean replacing the qp_solver.py in your installation with an updated version that I could point you at - it is being worked on for a PR to Aqua to address this and was still being tested. Would you like to give this a try? Alternatively if the data set you are using is publicly available it maybe something we can check out to ensure it works too.

@Supers25
Copy link
Author

Yes, please point me to the new version.

@woodsp-ibm
Copy link
Member

Ok, here is the updated file. It has a lambda2 value in there which defaults to 0.001. Hopefully it works with the default value but if not just try changing it a little bit bigger. We are working to expose this via QSVM so in practice it will be easier to set. But for now I think this should be ok to test things. Let us know how you get on with it https://github.com/sternparky/qiskit-aqua/blob/QSVM_update_Reg_Rotation/qiskit/aqua/utils/qp_solver.py

@Supers25
Copy link
Author

Thank you for the link! I will keep you updated.

@woodsp-ibm
Copy link
Member

@Supers25 Any update - did that help? As you can see a PR has been created that links to this issue. The PR locally fixes thing for the datasets we had seen the solver error but I was holding off merging to see if it solved things for you too. If so I will change the PR to have it auto-close this issue when it get merged.

@woodsp-ibm woodsp-ibm added the type: bug Something isn't working label Oct 23, 2020
@woodsp-ibm woodsp-ibm self-assigned this Oct 23, 2020
@Supers25
Copy link
Author

Thank you for checking in. The training is still running. I will keep you posted.

@Supers25
Copy link
Author

@woodsp-ibm It worked. Thank you for your help.

@woodsp-ibm
Copy link
Member

Great, thanks for the update. I'll approve the PR so the fix can be merged and be part of a future release.

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

Successfully merging a pull request may close this issue.

2 participants