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

Allow custom optimizers, improve JaxTrainingPlan #1747

Merged
merged 5 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions docs/release_notes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
This is the list of changes to scvi-tools between each release. Full commit history
is available in the [commit logs](https://github.com/YosefLab/scvi-tools/commits/).

## Version 0.19

```{toctree}
:maxdepth: 2

v0.19.0
```

## Version 0.18

```{toctree}
Expand Down
35 changes: 35 additions & 0 deletions docs/release_notes/v0.19.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# New in 0.19.0 (2022-MM-DD)

## Major Changes

- {class}`~scvi.train.TrainingPlan` allows custom PyTorch optimizers [#1747].
- Improvements to {class}`~scvi.train.JaxTrainingPlan` [#1747] [#1749].
- {class}`~scvi.module.base.LossRecorder` is deprecated. Please substitute with {class}`~scvi.module.base.LossOutput` [#1749]
- All training plans require keyword args after the first positional argument [#1749]

## Minor changes

## Breaking changes

- {class}`~scvi.module.base.LossRecorder` no longer allows access to dictionaries of values if provided during initialization [#1749].

## Bug Fixes

- Fix `n_proteins` usage in {class}`~scvi.model.MULTIVI` [#1737].
- Remove unused param in {class}`~scvi.model.MULTIVI` [#1741].

## Contributors

- [@watiss]
- [@adamgayoso]
- [@martinkim0]
- [@marianogabitto]

[#1737]: https://github.com/YosefLab/scvi-tools/pull/1737
[#1741]: https://github.com/YosefLab/scvi-tools/pull/1737
[#1747]: https://github.com/YosefLab/scvi-tools/pull/1747
[#1749]: https://github.com/YosefLab/scvi-tools/pull/1749
[@watiss]: https://github.com/watiss
[@adamgayoso]: https://github.com/adamgayoso
[@martinkim0]: https://github.com/martinkim0
[@marianogabitto]: https://github.com/marianogabitto
10 changes: 6 additions & 4 deletions scvi/model/base/_jaxmixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def train(
train_size: float = 0.9,
validation_size: Optional[float] = None,
batch_size: int = 128,
lr: float = 1e-3,
plan_kwargs: Optional[dict] = None,
**trainer_kwargs,
):
"""
Expand All @@ -43,6 +43,9 @@ def train(
Minibatch size to use during training.
lr
Learning rate to use during training.
plan_kwargs
Keyword args for :class:`~scvi.train.JaxTrainingPlan`. Keyword arguments passed to
`train()` will overwrite values present in `plan_kwargs`, when appropriate.
**trainer_kwargs
Other keyword args for :class:`~scvi.train.Trainer`.
"""
Expand Down Expand Up @@ -73,10 +76,9 @@ def train(
use_gpu=False,
iter_ndarray=True,
)
plan_kwargs = plan_kwargs if isinstance(plan_kwargs, dict) else dict()

self.training_plan = JaxTrainingPlan(
self.module, optim_kwargs=dict(learning_rate=lr)
)
self.training_plan = JaxTrainingPlan(self.module, **plan_kwargs)
if "callbacks" not in trainer_kwargs.keys():
trainer_kwargs["callbacks"] = []
trainer_kwargs["callbacks"].append(JaxModuleInit())
Expand Down
Loading