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

Add Differentiable CEM solver #329

Merged
merged 35 commits into from
Mar 23, 2023
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
31c277d
first implementation of dcem solver
dishank-b Oct 13, 2022
245d80c
dcem optimizer working
dishank-b Oct 14, 2022
11962c6
minor changes in dcem, added tests
dishank-b Oct 17, 2022
d069ee6
online calculatino of n_batch
dishank-b Oct 18, 2022
24d2fa9
initializing LML layer
dishank-b Oct 20, 2022
5632588
dcem working backwards tutorial 2
dishank-b Oct 28, 2022
655ba19
better vectorization in solver
dishank-b Oct 31, 2022
63a04cf
vectoriztion in solve method for itr loop in optimizer class
dishank-b Oct 31, 2022
fd93941
forward pass working perfectly with current set of hyperparams with b…
dishank-b Nov 3, 2022
976fb08
dcem backward unit test passed for one setting
dishank-b Nov 3, 2022
7547504
DCEM backward unit test working, not tested with leo, insanely slow w…
dishank-b Nov 4, 2022
3a22e09
refactoring, removed DcemSolver in favour of solve method in DCEM opt…
dishank-b Nov 4, 2022
89c8b39
correcting circle ci errors
dishank-b Nov 7, 2022
9bf03c4
corrected lml url for requirements.txt
dishank-b Nov 7, 2022
a1064a2
corrected reuirements.txt for lml
dishank-b Nov 7, 2022
c21dc69
removing -e from requirements
dishank-b Nov 8, 2022
c809e94
changing setup.py to install lml
dishank-b Nov 8, 2022
2bbf2db
changing setup.py to add lml
dishank-b Nov 8, 2022
4f3788c
commented dcem_test
dishank-b Nov 8, 2022
0f69df6
unit test working with both gpu, cpu with even less 10-2 error thres …
dishank-b Nov 9, 2022
0592f6f
testing with lml_eps=10-4
dishank-b Nov 10, 2022
7d68639
Revert "testing with lml_eps=10-4"
dishank-b Nov 10, 2022
044e881
reverting the common.py file
dishank-b Nov 10, 2022
769d483
dcem working, name changed from DCem to DCEM
dishank-b Mar 6, 2023
126ee47
removed _all_solve function and chnaged _solve name to _CEM_step
dishank-b Mar 6, 2023
f2ccf4b
changed dcem objective to use error_metric and edit __init files
dishank-b Mar 6, 2023
74a2a5d
dcem working, added dcem tutorial
dishank-b Mar 6, 2023
679dc3b
add lml as third party
dishank-b Mar 6, 2023
fab68be
or black pre-commit hook
dishank-b Mar 6, 2023
f4b345a
removeing abs in loss function since model chnaged test_theseus layer
dishank-b Mar 7, 2023
97c94b6
changes in test_theseus to make it compatible with DCEM
dishank-b Mar 9, 2023
bc32139
minor changes:styling, nits, typehinting, etc.
dishank-b Mar 17, 2023
50ea767
reverted minor changes, corrected test_theseus_layer argument logic f…
dishank-b Mar 20, 2023
ee75e95
using scatter for indexes with temp=None in dcem
dishank-b Mar 21, 2023
947e026
final changes, removing half-complete changes before merge
dishank-b Mar 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
reverting the common.py file
  • Loading branch information
dishank-b committed Mar 9, 2023
commit 044e88129b76c69a35f9e38fc5116bf41a4aebc5
18 changes: 6 additions & 12 deletions tests/optimizer/nonlinear/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ def _check_nonlinear_least_squares_fit(
initial_error = objective.error_metric()
max_iterations = 20
optimizer = nonlinear_optim_cls(objective)
# assert isinstance(optimizer.linear_solver, th.CholeskyDenseSolver)
assert isinstance(optimizer.linear_solver, th.CholeskyDenseSolver)
optimizer.set_params(max_iterations=max_iterations)

callback_expected_iter = [0]

def callback(opt_, info_, delta_, it_):
assert opt_ is optimizer
assert isinstance(info_, th.optimizer.OptimizerInfo)
# assert isinstance(delta_, torch.Tensor)
assert isinstance(delta_, torch.Tensor)
assert it_ == callback_expected_iter[0]
callback_expected_iter[0] += 1

Expand All @@ -163,13 +163,7 @@ def callback(opt_, info_, delta_, it_):
**optimize_kwargs,
)
# Solution must now match the true coefficients
print(variables[0].tensor)
print(
variables[0].tensor.abs().isclose(true_coeffs.repeat(batch_size, 1), atol=5e-2)
)
assert (
variables[0].tensor.abs().allclose(true_coeffs.repeat(batch_size, 1), atol=5e-2)
)
assert variables[0].tensor.allclose(true_coeffs.repeat(batch_size, 1), atol=1e-6)
_check_info(info, batch_size, max_iterations, initial_error, objective)


Expand Down Expand Up @@ -203,9 +197,9 @@ def _check_nonlinear_least_squares_fit_multivar(
objective.update(values)
initial_error = objective.error_metric()

max_iterations = 100
max_iterations = 20
optimizer = nonlinear_optim_cls(objective)
# assert isinstance(optimizer.linear_solver, th.CholeskyDenseSolver)
assert isinstance(optimizer.linear_solver, th.CholeskyDenseSolver)
optimizer.set_params(max_iterations=max_iterations)
info = optimizer.optimize(
track_best_solution=True, track_err_history=True, **optimize_kwargs
Expand Down Expand Up @@ -272,7 +266,7 @@ def _copy_impl(self):
objective.update(values)

optimizer = nonlinear_optim_cls(objective, vectorize=False)
# assert isinstance(optimizer.linear_solver, th.CholeskyDenseSolver)
assert isinstance(optimizer.linear_solver, th.CholeskyDenseSolver)
optimizer.set_params(max_iterations=30)
optimizer.linear_solver.linearization = BadLinearization(objective)
with pytest.raises(RuntimeError):
Expand Down