-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
code refactor; added training strategies
- Loading branch information
Showing
17 changed files
with
297 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pytorch_lightning as pl | ||
|
||
from luxonis_train.strategies.base_strategy import BaseTrainingStrategy | ||
|
||
|
||
class TrainingManager(pl.Callback): | ||
def __init__(self, strategy: BaseTrainingStrategy | None = None): | ||
"""Training manager callback that updates the parameters of the | ||
training strategy. | ||
@type strategy: BaseTrainingStrategy | ||
@param strategy: The strategy to be used. | ||
""" | ||
self.strategy = strategy | ||
|
||
def on_after_backward( | ||
self, trainer: pl.Trainer, pl_module: pl.LightningModule | ||
): | ||
"""PyTorch Lightning hook that is called after the backward | ||
pass. | ||
@type trainer: pl.Trainer | ||
@param trainer: The trainer object. | ||
@type pl_module: pl.LightningModule | ||
@param pl_module: The pl_module object. | ||
""" | ||
if self.strategy is not None: | ||
self.strategy.update_parameters(pl_module) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.