help defining new training_step() on a callback #12442
Answered
by
rohitgr7
malfonsoarquimea
asked this question in
Lightning Trainer API: Trainer, LightningModule, LightningDataModule
-
Beta Was this translation helpful? Give feedback.
Answered by
rohitgr7
Mar 24, 2022
Replies: 1 comment 1 reply
-
hey @malfonsoarquimea !
class CustomCallback(Callback):
def __init__(..., every_n_train_steps):
self.every_n_train_steps = every_n_train_steps
...
def on_train_batch_end(self, trainer, pl_module, *args, **kwargs):
if trainer.global_step % self.every_n_train_steps == 0:
outputs = pl_module(self.input) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
malfonsoarquimea
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hey @malfonsoarquimea !
Callback.training_step
is not a hook so it won't be called automatically. For you use-case you can do something like: