Class FullyConnectedLayer

All Implemented Interfaces:
Backward, Forward, Layer<TensorBase>, Serializable

public class FullyConnectedLayer extends AbstractLayer<TensorBase, TensorBase, Tensor2D>
Fully connected layer is used as a hidden layer in a neural network, and it has a single row of units/nodes/neurons connected to all neurons in previous and next layer. Previous layer can be input, fully connected, or flattened layer, while next layer can be fully connected or output layer. This layer calculates weighted sum of outputs from the previous layers (as matrix dot product), and applies activation function to all that sum. Mathematical formula is: Y = activation(W . X + B) where Y is output tensor (1D for single input or 2D for batch) W is a 2D weights tensor X is input tensor (1D for single input or 2D for batch) B is a 1D tensor of biases activation is an activation function
See Also:
  • Constructor Details

    • FullyConnectedLayer

      public FullyConnectedLayer(int layerSize)
      Creates an instance of fully connected layer with specified number of neurons and ReLU activation function.
      Parameters:
      layerSize - a number of neurons in this layer / layer size (same as number of outputs)
    • FullyConnectedLayer

      public FullyConnectedLayer(int layerSize, ActivationType actType)
      Creates an instance of a fully connected layer with specified width (number of neurons) and activation function type.
      Parameters:
      layerSize - layer size / number of neurons in this layer
      actType - activation function type to use in this layer
      See Also:
      • invalid reference
        ActivationFunctions
  • Method Details