CQCL / lambeq

A high-level Python library for Quantum Natural Language Processing
https://docs.quantinuum.com/lambeq/
Apache License 2.0
455 stars 111 forks source link

[UnitaryHack] Implementation of Nelder Mead Optimizer #104

Closed Gopal-Dahale closed 1 year ago

Gopal-Dahale commented 1 year ago

Purpose

Implemented the Nelder Mead Optimizer.

Details

The optimizer along with tests. Also added the jupyter notebook used to test the optimizer. I have used 200 epochs instead of 100 as the optimizer required more epochs for convergence. This PR resolves #85.

Results

I ran two tests with adaptive equal to True and False for 200 epochs.

  1. adaptive=False, final output is 0.98555, 0.01445

  2. adaptive=True, final output is 0.96625, 0.03375

dimkart commented 1 year ago

@Gopal-Dahale Hi and thanks for this. There are some linting errors, could you fix them?

Gopal-Dahale commented 1 year ago

Hi @dimkart, I have formatted the code and ran the two commands locally and both of them now give 0:

  1. flake8 lambeq --max-doc-length=74
  2. flake8 lambeq --count --isolated --select=E9,F63,F7,F82 --show-source --statistics
Gopal-Dahale commented 1 year ago

Hi @dimkart, I see type check with mypy has failed. I'll fix it. Meanwhile, is there documentation on how to build and test lambeq locally so that I don't have to rely on GitHub actions until I fix them all locally?

dimkart commented 1 year ago

Hi @dimkart, I see type check with mypy has failed. I'll fix it. Meanwhile, is there documentation on how to build and test lambeq locally so that I don't have to rely on GitHub actions until I fix them all locally?

Unfortunately there is no documentation for that, but running pytest and mypy locally should work. Check the github actions (build_test.yml) to see the command lines we use for any special options or exclusion of files.

Gopal-Dahale commented 1 year ago

Thanks. I have fixed the mypy issue and now it gives Success: no issues found in 58 source files.

dimkart commented 1 year ago

@Gopal-Dahale Thanks, tests are now passing. This look already very good, and tomorrow we'll have a closer look at the code and we'll run the notebook to check performance. If you have already tried to run the notebook you might post here a screenshot of the trainer output for comparison. Keep an eye here for new comments :)

Gopal-Dahale commented 1 year ago

Hi, @Thommy257 @ianyfan can you resolve the conversations?

dimkart commented 1 year ago

@Gopal-Dahale Hi, thanks for taking the time to respond to all comments -- the conversations will be resolved tomorrow by Ian and Thomas.

Thommy257 commented 1 year ago

Let's remove the notebook as well

Gopal-Dahale commented 1 year ago

Hi @ianyfan, I had updated the code as per your comments. Can you resolve the conversations?