Skip to Content
机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)
book

机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)

by Aurélien Géron
October 2020
Intermediate to advanced
693 pages
16h 26m
Chinese
China Machine Press
Content preview from 机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)
训练深度神经网络
321
中可以使用的调度之一来定义学习率,然后将该学习率传递给任意优化器。这种方
法在每个步骤更新学习率而不是每个轮次。例如,以下是实现与我们先前定义的
exponential_decay_fn() 函数相同的指数调度的方法:
s = 20 * len(X_train) // 32 #
number of steps in 20 epochs (batch size = 32)
learning_rate = keras.optimizers.schedules.ExponentialDecay(0.01, s, 0.1)
optimizer = keras.optimizers.SGD(learning_rate)
这很简单,而且当你保存模型时,学习率及其调度(包括其状态)也将被保存。但是,
这种方法不是 Keras API 的一部分,它只适用于 tf.keras
对于 1 周期方法,实现起来没有特别的困难:只需创建一个每次迭代都能修改学习率的
自定义回调函数即可(你可以通过更改 self.model.optimizer.lr 来更新优化器的
学习率)。有关示例请参见 notebook 的“lycle scheduling”部分。
总而言之,指数衰减、性能调度和 1 周期都可以大大加快收敛速度 ,因此请尝试一下!
11.4 通过正则化避免过拟合
有了 4 个参数,我可以拟合出一头大象,有了 5 个参数,我可以让它摆动鼻子。
John von NeumannEnrico Fermi ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

算法技术手册(原书第2 版)

算法技术手册(原书第2 版)

George T.Heineman, Gary Pollice, Stanley Selkow
Go语言编程

Go语言编程

威廉·肯尼迪
管理Kubernetes

管理Kubernetes

Brendan Burns, Craig Tracey

Publisher Resources

ISBN: 9787111665977