7.1.4正向传播
前文中反复提到两个关键词:“线性组合”和“激活函数”,就是神经网络的两大“法宝”。很多人喜欢把神经网络看成一个黑匣子,认为从输入到输出之间经过了复杂的计算程序。不过看清这个计算过程之后,其实整个流程很简单,就是不断重复“线性组合”和“激活”的过程:
$$
\begin{array} { r } \frac { d ^ { 2 } \sinh } { d \sinh } \lambda \frac { - 4 \sinh } { 2 \sqrt { 3 } } + \frac { 1 + 4 \cosh } { 2 \sqrt { 2 } } \frac { \sinh } { \sinh } \frac { \sinh } { 2 \cosh } + \frac { 4 \sinh } { 2 \sqrt { 3 } } \frac { 1 + 4 \cosh } { 2 \sqrt { 3 } } \frac { \sinh } { \cosh } + \frac { \sqrt { 6 } \sqrt { 7 } \sqrt { 2 } \sinh } { 2 \sqrt { 3 } } \frac { 1 + \cosh } { 2 \sqrt { 3 } \sqrt { 1 + 4 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } { 2 \sqrt { 3 } } \frac { 1 + \sinh } 2 \sqrt \end{array}
$$
像这样从输入端 $\mathbf { X } _ { 1 } , \mathbf { X } _ { 2 } , \ldots$ 到输出端生成y的计算过程叫作正向传播(forward propagation)。上述步骤正是正向传播的步骤。在给定各层权重参数的情况下,我们可以通过正向传播由已知x,计算出y。至此,我们知道了神经网络是如何从输入计算到输出的。
7.1.5激活函数
神经网络的核心在于激活函数。激活函数的存在使得神经网络由线性变为非线性。如果不使用激活函数或者使用线性激活函数都不能达到这个目的。这是因为线性组合的线性组合仍然是原变量的线性组合。激活函数通常有ReLU、Sigmoid、Tanh等。读者在没有具体的想法时,不妨尝试使用以上几种主流的选择,特别是ReLU。这个函数虽然简单,但随着时间的推移,人们发现这个激活函数不仅会给运算上带来方便,效果在很多实际问题中也是最好的。早期一些学者的论文中使用Sigmoid以及其他激活函数的地方在如今的应用中都被换成了ReLU。
7.2 神经网络的训练
7.2.1 神经网络的参数
要使神经网络模型具有预测能力,我们必须要让输入和输出之间的道路“畅通”。要达到这一点,我们需要训练神经网络中的参数。那么神经网络的参数究竟有哪些呢?读者可以试着想一下,图7-8中的神经网络包含多少个参数。
第7章 深度学习
197