Callbacks
Weights & Biases Logging callback. To use this callback pip install wandb
.
Any metric that contains epoch
will be plotted with epoch
and all the other metrics will be plotted against
global_step
which is total training steps. You can change the default axis by providing default_step_metric
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
log_model |
bool |
Whether to upload model artifact to Wandb |
False |
code_file |
Optional[str] |
path of the code you want to upload as artifact to Wandb |
None |
default_step_metric |
Metrics will be plotted against the |
'global_step' |
from gradsflow.callbacks import WandbCallback
from timm import create_model
cnn = create_model("resnet18", pretrained=False, num_classes=1)
model = Model(cnn)
model.compile()
cb = WandbCallback()
autodataset = None # create your dataset
model.fit(autodataset, callbacks=cb)
Tracks the carbon emissions produced by deep neural networks using
CodeCarbon. To use this callback first install codecarbon using
pip install codecarbon
.
For offline use, you must have to specify the country code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offline |
bool |
whether to use internet connection or not. You will have to provide the country code |
False |
**kwargs |
passed directly to codecarbon class. |
{} |
on_fit_end(self)
¶
Called after model.fit(...)
Comet Logging callback.
This callback requires comet-ml
to be pre-installed (pip install comet-ml
).
Automatically log your Experiment to Comet logging platform. You need to provide API key either by setting
environment variable COMET_API_KEY
or directly pass as an argument to the callback.
Checkout the documentation for more examples.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name |
str |
Name of the Project |
'awesome-project' |
api_key |
Optional[str] |
project API key |
None |
offline |
bool |
log experiment offline |
False |
on_epoch_end(self)
¶
Called after each epoch
on_fit_start(self)
¶
Called on each model.fit(...)
on_train_epoch_start(self)
¶
Called on start of training epoch
on_train_step_end(self, outputs=None, **_)
¶
Called after training step
on_val_epoch_start(self)
¶
Called on start of validation epoch
on_val_step_end(self, outputs=None, **_)
¶
Called after validation step