myco.callbacks¶
Functions to report on active model training status.
CyclicLRPolicy
¶
Bases: tf.keras.callbacks.Callback
Cyclically modify learning rates
Source code in myco/callbacks.py
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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
__init__(min_lr=0.0001, max_lr=None, lr_range_scaler=10, mode='one_cycle', momentum=0.8, sample_size=None, batch_size=None, step_factor=1)
¶
Create a cyclic learning rate callback to modify LR by batch.
Reference: L.N. Smith 2017 arxiv.org/pdf/1506.01186.pdf
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min_lr |
float
|
minimum bounding learning rate. |
0.0001
|
max_lr |
float
|
maximum bounding learning rate. |
None
|
lr_range_scaler |
float
|
set the maximum learning rate by scaling the minimum learning rate. if min_lr = 0.001 and lr_range_scaler = 20, then max_lr is set to 0.02. this is ignored if max_lr is passed. |
10
|
mode |
str
|
cyclic method. options include: [one_cycle, cos_annealing, multi_triangular, exp_range]. |
'one_cycle'
|
momentum |
float
|
rate of change for exp_range mode. higher numbers slow the the rate of change decrease. |
0.8
|
sample_size |
int
|
total number of samples in an epoch. |
None
|
batch_size |
int
|
number of samples in a batch. |
None
|
step_factor |
int
|
number of epochs over which to run half a cycle. set this to 1 to scale from min to max in one epoch, then from max to min in the next. |
1
|
Source code in myco/callbacks.py
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 112 113 114 115 116 117 118 119 120 121 122 123 |
|
GarbageCollector
¶
Bases: tf.keras.callbacks.Callback
Clears memory leaks
Source code in myco/callbacks.py
50 51 52 53 54 55 56 57 58 59 |
|
LrFinder
¶
Bases: tf.keras.callbacks.Callback
This callback uses exponential annealing to find the loss value per lr in a range default range value from start_lr=1e-10 to end_lr=1e1
Source code in myco/callbacks.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
MemoryCallback
¶
Bases: tf.keras.callbacks.Callback
Print memory callbacks
Source code in myco/callbacks.py
37 38 39 40 41 42 43 44 45 46 47 |
|
MycoTensorBoard
¶
Bases: tf.keras.callbacks.TensorBoard
Extends tensorboard to report additional logging information
Source code in myco/callbacks.py
62 63 64 65 66 67 68 69 70 71 72 |
|
get_required_callbacks(model_path, best_only=True)
¶
Creates list of required model callbacks for model training.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_path |
str
|
Output filepath for model. |
required |
Returns:
Type | Description |
---|---|
List[tf.keras.callbacks.Callback]
|
List of model callbacks. |
Source code in myco/callbacks.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|