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

Add log_freq param to WandbCallback #3401

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 12 additions & 6 deletions nbs/70_callback.wandb.ipynb
Expand Up @@ -100,14 +100,14 @@
" # Record if watch has been called previously (even in another instance)\n",
" _wandb_watch_called = False\n",
"\n",
" def __init__(self, log=\"gradients\", log_preds=True, log_model=True, log_dataset=False, dataset_name=None, valid_dl=None, n_preds=36, seed=12345, reorder=True):\n",
" def __init__(self, log=\"gradients\", log_preds=True, log_model=True, log_dataset=False, dataset_name=None, valid_dl=None, n_preds=36, seed=12345, reorder=True, log_freq=1000):\n",
" # Check if wandb.init has been called\n",
" if wandb.run is None:\n",
" raise ValueError('You must call wandb.init() before WandbCallback()')\n",
" # W&B log step\n",
" self._wandb_step = wandb.run.step - 1 # -1 except if the run has previously logged data (incremented at each batch)\n",
" self._wandb_epoch = 0 if not(wandb.run.step) else math.ceil(wandb.run.summary['epoch']) # continue to next epoch\n",
" store_attr('log,log_preds,log_model,log_dataset,dataset_name,valid_dl,n_preds,seed,reorder')\n",
" store_attr('log,log_preds,log_model,log_dataset,dataset_name,valid_dl,n_preds,seed,reorder,log_freq')\n",
"\n",
" def before_fit(self):\n",
" \"Call watch method to log model topology, gradients & weights\"\n",
Expand All @@ -125,7 +125,7 @@
" if not WandbCallback._wandb_watch_called:\n",
" WandbCallback._wandb_watch_called = True\n",
" # Logs model topology and optionally gradients and weights\n",
" wandb.watch(self.learn.model, log=self.log)\n",
" wandb.watch(self.learn.model, log=self.log, log_freq=self.log_freq)\n",
"\n",
" # log dataset\n",
" assert isinstance(self.log_dataset, (str, Path, bool)), 'log_dataset must be a path or a boolean'\n",
Expand Down Expand Up @@ -873,15 +873,21 @@
}
],
"metadata": {
"interpreter": {
"hash": "10951ab8608296a5a0cdeec1a18304ecb3d7c26209d7d704833d6e1ee4f84e7e"
},
"jupytext": {
"split_at_heading": true
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"display_name": "Python 3.9.5 64-bit ('fastaidev': conda)",
"name": "python3"
},
"language_info": {
"name": "python",
"version": ""
}
},
"nbformat": 4,
"nbformat_minor": 4
}
}