基本神经网络中修正线性函数的用途是什么

What is the use of a rectified linear function in a basic neural network

我最近一直在研究神经网络及其在应用程序中的用途。就在最近,我看到了一个描述神经网络的教程,该神经网络将学习如何对 0-9 的手写数字进行分类 (MNIST)。我遇到问题的教程代码部分如下(https://pythonprogramming.net/tensorflow-neural-network-session-machine-learning-tutorial/)

def neural_network_model(data):
    hidden_1_layer = {'weights':tf.Variable(tf.random_normal([784, nodes_hl1])),
                'biases':tf.Variable(tf.random_normal([nodes_hl1]))}

    hidden_2_layer = {'weights':tf.Variable(tf.random_normal([nodes_hl1, nodes_hl2])),
                'biases':tf.Variable(tf.random_normal([nodes_hl2]))}

    hidden_3_layer = {'weights':tf.Variable(tf.random_normal([nodes_hl2, nodes_hl3])),
                'biases':tf.Variable(tf.random_normal([nodes_hl3]))}

    output_layer = {'weights':tf.Variable(tf.random_normal([nodes_hl3, n_classes])),
                'biases':tf.Variable(tf.random_normal([n_classes])),}


    l1 = tf.add(tf.matmul(data,hidden_1_layer['weights']), hidden_1_layer['biases'])
    l1 = tf.nn.relu(l1)

    l2 = tf.add(tf.matmul(l1,hidden_2_layer['weights']), hidden_2_layer['biases'])
    l2 = tf.nn.relu(l2)

    l3 = tf.add(tf.matmul(l2,hidden_3_layer['weights']), hidden_3_layer['biases'])
    l3 = tf.nn.relu(l3)

    output = tf.matmul(l3,output_layer['weights']) + output_layer['biases']

    return output

我对发生的事情有了基本的了解。 3 个隐藏层中的每一个都是一组由偏差和权重连接的节点。最后的输出层是神经网络的结果。我明白这里的一切,除了包含 tf.nn.relu() 的代码行。查看 TensorFlow 的文档后,它只提到该函数计算特征的修正线性(https://www.tensorflow.org/api_docs/python/nn/activation_functions_#relu)。我很困惑这个函数在执行什么,以及它在神经网络中有什么意义。

relu的一些优点(修正线性单元是)

  • 计算成本更低(因此性能更好)
  • Sigmoid 等其他一些函数趋于饱和
  • 他们有易于计算的导数(记住训练过程依赖于导数)

请检查这个https://www.quora.com/What-are-the-benefits-of-using-rectified-linear-units-vs-the-typical-sigmoid-activation-function