Skip to content

Commit cbe2fc7

Browse files
author
Henry Webel
authored
callback begin_* -> before_* (#458)
1 parent 93d7698 commit cbe2fc7

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

16_accel_sgd.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@
998998
"\n",
999999
"```python\n",
10001000
"try:\n",
1001-
" self._split(b); self('begin_batch')\n",
1001+
" self._split(b); self('before_batch')\n",
10021002
" self.pred = self.model(*self.xb); self('after_pred')\n",
10031003
" self.loss = self.loss_func(self.pred, *self.yb); self('after_loss')\n",
10041004
" if not self.training: return\n",
@@ -1027,17 +1027,17 @@
10271027
"source": [
10281028
"When you want to write your own callback, the full list of available events is:\n",
10291029
"\n",
1030-
"- `begin_fit`:: called before doing anything; ideal for initial setup.\n",
1031-
"- `begin_epoch`:: called at the beginning of each epoch; useful for any behavior you need to reset at each epoch.\n",
1032-
"- `begin_train`:: called at the beginning of the training part of an epoch.\n",
1033-
"- `begin_batch`:: called at the beginning of each batch, just after drawing said batch. It can be used to do any setup necessary for the batch (like hyperparameter scheduling) or to change the input/target before it goes into the model (for instance, apply Mixup).\n",
1030+
"- `before_fit`:: called before doing anything; ideal for initial setup.\n",
1031+
"- `before_epoch`:: called at the beginning of each epoch; useful for any behavior you need to reset at each epoch.\n",
1032+
"- `before_train`:: called at the beginning of the training part of an epoch.\n",
1033+
"- `before_batch`:: called at the beginning of each batch, just after drawing said batch. It can be used to do any setup necessary for the batch (like hyperparameter scheduling) or to change the input/target before it goes into the model (for instance, apply Mixup).\n",
10341034
"- `after_pred`:: called after computing the output of the model on the batch. It can be used to change that output before it's fed to the loss function.\n",
10351035
"- `after_loss`:: called after the loss has been computed, but before the backward pass. It can be used to add penalty to the loss (AR or TAR in RNN training, for instance).\n",
10361036
"- `after_backward`:: called after the backward pass, but before the update of the parameters. It can be used to make changes to the gradients before said update (via gradient clipping, for instance).\n",
10371037
"- `after_step`:: called after the step and before the gradients are zeroed.\n",
10381038
"- `after_batch`:: called at the end of a batch, to perform any required cleanup before the next one.\n",
10391039
"- `after_train`:: called at the end of the training phase of an epoch.\n",
1040-
"- `begin_validate`:: called at the beginning of the validation phase of an epoch; useful for any setup needed specifically for validation.\n",
1040+
"- `before_validate`:: called at the beginning of the validation phase of an epoch; useful for any setup needed specifically for validation.\n",
10411041
"- `after_validate`:: called at the end of the validation part of an epoch.\n",
10421042
"- `after_epoch`:: called at the end of an epoch, for any cleanup before the next one.\n",
10431043
"- `after_fit`:: called at the end of training, for final cleanup.\n",
@@ -1059,8 +1059,8 @@
10591059
"outputs": [],
10601060
"source": [
10611061
"class ModelResetter(Callback):\n",
1062-
" def begin_train(self): self.model.reset()\n",
1063-
" def begin_validate(self): self.model.reset()"
1062+
" def before_train(self): self.model.reset()\n",
1063+
" def before_validate(self): self.model.reset()"
10641064
]
10651065
},
10661066
{

0 commit comments

Comments
 (0)