-
-
Notifications
You must be signed in to change notification settings - Fork 385
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
[wip] FAQ #988
[wip] FAQ #988
Changes from 2 commits
f7eba98
e29b8fb
ebb636f
4485607
792f098
a1a544b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,44 @@ | |
|
||
|
||
class CheckRunCallback(Callback): | ||
"""Executes only a pipeline part from the ``Experiment``.""" | ||
"""Executes only a pipeline part from the ``Experiment``. | ||
|
||
Minimal working example (Notebook API): | ||
|
||
.. code-block:: python | ||
|
||
import torch | ||
from torch.utils.data import DataLoader, TensorDataset | ||
from catalyst import dl | ||
|
||
# data | ||
num_samples, num_features = int(1e4), int(1e1) | ||
X, y = torch.rand(num_samples, num_features), torch.rand(num_samples) | ||
dataset = TensorDataset(X, y) | ||
loader = DataLoader(dataset, batch_size=32, num_workers=1) | ||
loaders = {"train": loader, "valid": loader} | ||
|
||
# model, criterion, optimizer, scheduler | ||
model = torch.nn.Linear(num_features, 1) | ||
criterion = torch.nn.MSELoss() | ||
optimizer = torch.optim.Adam(model.parameters()) | ||
scheduler = torch.optim.lr_scheduler.MultiStepLR(optimizer, [3, 6]) | ||
|
||
# model training | ||
runner = dl.SupervisedRunner() | ||
runner.train( | ||
model=model, | ||
criterion=criterion, | ||
optimizer=optimizer, | ||
scheduler=scheduler, | ||
loaders=loaders, | ||
logdir="./logdir", | ||
num_epochs=8, | ||
verbose=True, | ||
callbacks=[dl.CheckRunCallback(num_batch_steps=3, num_epoch_steps=3)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pep8] reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pep8] reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pep8] reported by reviewdog 🐶 |
||
) | ||
|
||
""" | ||
|
||
def __init__(self, num_batch_steps: int = 3, num_epoch_steps: int = 2): | ||
""" | ||
|
@@ -41,24 +78,40 @@ def on_batch_end(self, runner: "IRunner"): | |
class EarlyStoppingCallback(Callback): | ||
"""Early exit based on metric. | ||
|
||
Example of usage in notebook API: | ||
Minimal working example (Notebook API): | ||
|
||
.. code-block:: python | ||
|
||
runner = SupervisedRunner() | ||
import torch | ||
from torch.utils.data import DataLoader, TensorDataset | ||
from catalyst import dl | ||
|
||
# data | ||
num_samples, num_features = int(1e4), int(1e1) | ||
X, y = torch.rand(num_samples, num_features), torch.rand(num_samples) | ||
dataset = TensorDataset(X, y) | ||
loader = DataLoader(dataset, batch_size=32, num_workers=1) | ||
loaders = {"train": loader, "valid": loader} | ||
|
||
# model, criterion, optimizer, scheduler | ||
model = torch.nn.Linear(num_features, 1) | ||
criterion = torch.nn.MSELoss() | ||
optimizer = torch.optim.Adam(model.parameters()) | ||
scheduler = torch.optim.lr_scheduler.MultiStepLR(optimizer, [3, 6]) | ||
|
||
# model training | ||
runner = dl.SupervisedRunner() | ||
runner.train( | ||
... | ||
callbacks=[ | ||
... | ||
EarlyStoppingCallback( | ||
patience=5, | ||
metric="my_metric", | ||
minimize=True, | ||
) | ||
... | ||
] | ||
model=model, | ||
criterion=criterion, | ||
optimizer=optimizer, | ||
scheduler=scheduler, | ||
loaders=loaders, | ||
logdir="./logdir", | ||
num_epochs=8, | ||
verbose=True, | ||
callbacks=[dl.EarlyStoppingCallback(patience=2, metric="loss", minimize=True)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pep8] reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pep8] reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pep8] reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pep8] reported by reviewdog 🐶 |
||
) | ||
... | ||
|
||
Example of usage in config API: | ||
|
||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Callback | ||
============================================================================== | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Experiment | ||
============================================================================== | ||
|
||
Experiment - an abstraction that contains information about the experiment | ||
- a model, a criterion, an optimizer, a scheduler, and their hyperparameters. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
It also has information about the data and transformations used. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
The Experiment knows **what** you would like to run. | ||
|
||
Each deep learning project has several main components. | ||
These primitives define what we want to use during the experiment: | ||
|
||
- the data | ||
- the model(s) | ||
- the optimizer(s) | ||
- the loss(es) | ||
- and the scheduler(s) if we need them. | ||
|
||
That are the abstractions that Experiment covers in Catalyst, | ||
with a few modifications for easier experiment monitoring | ||
and hyperparameters logging. For each stage of our experiment, | ||
the Experiment provides interfaces to all primitives above + the callbacks. | ||
|
||
.. image:: https://raw.githubusercontent.com/catalyst-team/catalyst-pics/master/third_party_pics/catalyst102-experiment.png | ||
:alt: Experiment | ||
|
||
|
||
--- | ||
|
||
- what is the difference between different Experiments? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Runner | ||
============================================================================== | ||
|
||
--- | ||
|
||
- what is the difference between different Runners? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Mixed precision training | ||
============================================================================== | ||
|
||
- How to use Nvidia Apex? | ||
- How to use torch.amp? | ||
|
||
If you haven't found the answer for your question, feel free to `join our slack`_ for the discussion. | ||
|
||
.. _`join our slack`: https://join.slack.com/t/catalyst-team-core/shared_invite/zt-d9miirnn-z86oKDzFMKlMG4fgFdZafw |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Model checkpointing | ||
============================================================================== | ||
|
||
- how to load bset model? | ||
- notebook and config api | ||
- how to save model? | ||
- how to load model? | ||
- whats the difference between checkpoint and checkpoint_full? | ||
|
||
If you haven't found the answer for your question, feel free to `join our slack`_ for the discussion. | ||
|
||
.. _`join our slack`: https://join.slack.com/t/catalyst-team-core/shared_invite/zt-d9miirnn-z86oKDzFMKlMG4fgFdZafw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
E501 line too long (81 > 79 characters)