Dense реализует операцию: output = activation(dot(input, kernel) + bias)
, где активация - это поэлементная функция активации, переданная в качестве аргумента активации, ядро - это матрица весов, созданная слоем, а смещение - вектор смещения, созданный слоем (применимо, только если use_bias - True).
Примечание. Если входное значение слоя имеет ранг, превышающий 2, то оно выравнивается до начального точечного произведения с ядром.
Пример:
# as first layer in a sequential model:
model = Sequential()
model.add(Dense(32, input_shape=(16,)))
# now the model will take as input arrays of shape (*, 16)
# and output arrays of shape (*, 32)
# after the first layer, you don't need to specify
# the size of the input anymore:
model.add(Dense(32))
Аргументы:
> 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.
>kernel_regularizer:Regularizer function applied to the kernel weights matrix.
> bias_regularizer: Regularizer function applied to the bias vector.
> activity_regularizer: Regularizer function applied to the output of the layer (its "activation")..
>kernel_constraint: Constraint function applied to the kernel weights matrix.
>bias_constraint: Constraint function applied to the bias vector.
Форма ввода:
Тензор ND с формой: (batch_size, ..., input_dim). Наиболее распространенной ситуацией может быть двумерный ввод с формой (batch_size, input_dim).
Форма вывода:
Тензор ND с формой: (batch_size, ..., unit). Например, для двумерного ввода с формой (batch_size, input_dim) выход будет иметь форму (batch_size, единицы).