hooks
EarlyStoppingHook
#
Bases: HookBase
Source code in focoos/trainer/hooks/early_stop.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
__init__(enabled, eval_period, patience, val_metric, mode='max')
#
Initializes the EarlyStoppingHook.
This hook is designed to monitor a specific validation metric during the training process and stop training when no improvement is observed in the metric for a specified number of iterations. This is particularly useful for preventing overfitting by halting training once the model's performance on the validation set no longer improves.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
eval_period
|
int
|
The frequency (in iterations) at which the validation metric is evaluated.
For example, if |
required |
patience
|
int
|
Number of consecutive evaluations with no improvement after which training will be stopped.
For example, if |
required |
val_metric
|
str
|
The name of the validation metric to monitor. This should correspond to one of the metrics calculated during the validation phase, such as "accuracy", "loss", etc. |
required |
mode
|
str
|
One of "min" or "max". This parameter dictates the direction of improvement for the validation metric. In "min" mode, the training will stop when the monitored quantity (e.g., loss) stops decreasing. In "max" mode, training will stop when the monitored quantity (e.g., accuracy) stops increasing. Defaults to "max". |
'max'
|
Source code in focoos/trainer/hooks/early_stop.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
SyncToHubHook
#
Bases: HookBase
Source code in focoos/trainer/hooks/sync_to_hub.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
before_train()
#
Called before the first iteration.
Source code in focoos/trainer/hooks/sync_to_hub.py
37 38 39 40 41 42 43 44 45 46 47 |
|