self.dense = tf.keras.layers.Dense(units=1, kernel_initializer=tf.zeros_initializer(),
bias_initializer=tf.zeros_initializer())
units: Positive integer, dimensionality of the output space.
activation: Activation function to use. If you don’t specify anything, no activation is applied (ie. “linear” activation: a(x) = x).
use_bias: Boolean, whether the layer uses a bias vector.
kernel_initializer: Initializer for the kernel weights matrix.
bias_initializer: Initializer for the bias vector.
这个全连接层封装了output = activation(tf.matmul(input, kernel) + bias)
这一线性变换+激活函数的计算操作,以及 kernel 和 bias 两个变量。当不指定激活函数时(即 activation(x) = x ),这个全连接
层就等价于我们上述的线性变换。
值得一提的是,全连接层可能是我们编写模型时使用最频繁的层。
本文深入探讨了全连接层在神经网络中的作用,包括其输出维度、激活函数、偏置项、权重矩阵初始化及偏置向量初始化。阐述了全连接层如何执行线性变换加激活函数计算,以及在不指定激活函数时,它等同于线性变换。此外,还强调了全连接层在模型构建中的重要地位。
1729

被折叠的 条评论
为什么被折叠?



