Rephrase a commentand delete one
Suggestions from @rchao
This commit is contained in:
parent
0c41783977
commit
1662bdc253
@ -1172,15 +1172,15 @@ class LearningRateScheduler(Callback):
|
|||||||
```python
|
```python
|
||||||
# Firstly, let's create a function which
|
# Firstly, let's create a function which
|
||||||
# maps a given epoch to a learning rate.
|
# maps a given epoch to a learning rate.
|
||||||
# This function would keep the learning rate
|
# This function keeps the learning rate
|
||||||
# constant at 0.001 for the first ten epochs and
|
# at 0.001 for the first ten epochs and
|
||||||
# let it decrease exponentially after that.
|
# decreases it exponentially after that.
|
||||||
def scheduler(epoch):
|
def scheduler(epoch):
|
||||||
if epoch < 10:
|
if epoch < 10:
|
||||||
return 0.001
|
return 0.001
|
||||||
else:
|
else:
|
||||||
return 0.001 * tf.math.exp(0.1 * (10 - epoch))
|
return 0.001 * tf.math.exp(0.1 * (10 - epoch))
|
||||||
# Next, we need to set up the callback and train the model.
|
|
||||||
callback = tf.keras.callbacks.LearningRateScheduler(scheduler)
|
callback = tf.keras.callbacks.LearningRateScheduler(scheduler)
|
||||||
model.fit(data, labels, epochs=100, callbacks=[callback],
|
model.fit(data, labels, epochs=100, callbacks=[callback],
|
||||||
validation_data=(val_data, val_labels))
|
validation_data=(val_data, val_labels))
|
||||||
|
Loading…
Reference in New Issue
Block a user