Dense¶
-
class
Dense(units, activation=None, use_bias=True, flatten=True, dtype='float32', weight_initializer=None, bias_initializer='zeros', in_units=0, **kwargs)¶ Just your regular densely-connected NN layer.
Dense implements the operation: output = activation(dot(input, weight) + bias) where activation is the element-wise activation function passed as the activation argument, weight is a weights matrix created by the layer, and bias is a bias vector created by the layer (only applicable if use_bias is True).
Note
the input must be a tensor with rank 2. Use flatten to convert it to rank 2 manually if necessary.
Parameters: - units : int
Dimensionality of the output space.
- activation : str
Activation function to use. See help on Activation layer. If you don’t specify anything, no activation is applied (ie. “linear” activation: a(x) = x).
- use_bias : bool, default True
Whether the layer uses a bias vector.
- flatten: bool, default True
Whether the input tensor should be flattened. If true, all but the first axis of input data are collapsed together. If false, all but the last axis of input data are kept the same, and the transformation applies on the last axis.
- dtype : str or np.dtype, default ‘float32’
Data type of output embeddings.
- weight_initializer : str or Initializer
Initializer for the kernel weights matrix.
- bias_initializer: str or `Initializer`
Initializer for the bias vector.
- in_units : int, optional
Size of the input data. If not specified, initialization will be deferred to the first time forward is called and in_units will be inferred from the shape of input data.
- prefix : str or None
See document of Block.
- params : ParameterDict or None
See document of Block.
- Inputs:
- data: if flatten is True, data should be a tensor with shape (batch_size, x1, x2, …, xn), where x1 * x2 * … * xn is equal to in_units. If flatten is False, data should have shape (x1, x2, …, xn, in_units).
- Outputs:
- out: if flatten is True, out will be a tensor with shape (batch_size, units). If flatten is False, out will have shape (x1, x2, …, xn, units).