Class FeedForwardNetwork.Builder

java.lang.Object
deepnetts.net.FeedForwardNetwork.Builder
Enclosing class:
FeedForwardNetwork

public static class FeedForwardNetwork.Builder extends Object
Builder of a FeedForwardNetwork instance. Provides methods for setting all the components of a feed forward neural network and performs basic validation of settings in order to prevent illegal configuration.
See Also:
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • addInputLayer

      public FeedForwardNetwork.Builder addInputLayer(int layerWidth)
      Adds input layer with the specified layerWidth (number of inputs) to the network. Input layer is always the first layer in the network which accepts the external input.
      Parameters:
      layerWidth - width of the input layer that corresponds to the number of network's inputs
      Returns:
      builder instance
    • addInputLayer

      public FeedForwardNetwork.Builder addInputLayer(int layerWidth, int batchSize)
    • addInputLayer

      public FeedForwardNetwork.Builder addInputLayer(int layerWidth, int batchSize, boolean isGpu)
    • addFullyConnectedLayer

      public FeedForwardNetwork.Builder addFullyConnectedLayer(int layerWidth)
      Adds to the network a fully connected layer with specified width and Relu activation function by default.
      Parameters:
      layerWidth - width of the layer / number of neurons
      Returns:
      builder instance
      See Also:
    • addHiddenFullyConnectedLayers

      public FeedForwardNetwork.Builder addHiddenFullyConnectedLayers(int... layerWidths)
      Adds to the network several hidden fully connected layers with specified widths and default hidden activation function by default.
      Parameters:
      layerWidths - an array with widths for hidden fully connected layers.
      Returns:
      builder instance
      See Also:
    • addFullyConnectedLayer

      public FeedForwardNetwork.Builder addFullyConnectedLayer(int layerWidth, ActivationType activationType)
      Adds fully connected addLayer with specified width and activation function to the network.
      Parameters:
      layerWidth - width of the layer to add
      activationType - type of the activation function for layer to add
      Returns:
      builder instance
      See Also:
    • addHiddenFullyConnectedLayers

      public FeedForwardNetwork.Builder addHiddenFullyConnectedLayers(ActivationType activationType, int... layerWidths)
      Adds fully connected hidden layers with widths given in layerWidths param and given activation function type.
      Parameters:
      activationType - type of activation function in hidden layers
      layerWidths - widths of the hidden layers
      Returns:
    • addLayer

      public FeedForwardNetwork.Builder addLayer(AbstractLayer layer)
      Adds custom layer to this network (which inherits from AbstractLayer)
      Parameters:
      layer -
      Returns:
      builder instance
    • addOutputLayer

      public FeedForwardNetwork.Builder addOutputLayer(int width, ActivationType activationType)
      Adds output layer to the neural network with specified width (number of outputs) and activation function type.
      Parameters:
      width - layer with which corresponds to number of network's outputs
      activationType - type of the activation function to use in output layer
      Returns:
      builder instance
    • hiddenActivationFunction

      public FeedForwardNetwork.Builder hiddenActivationFunction(ActivationType activationType)
      Sets default type of the activation function to use for all hidden layers in the network.
      Parameters:
      activationType - type of activation function
      Returns:
      instance of the current builder
      See Also:
    • lossFunction

      public FeedForwardNetwork.Builder lossFunction(LossType lossType)
      Sets loss function to be used by created neural network. Loss function calculates the network's error during the training as a difference between actual and target output provided in training set.
      Parameters:
      lossType - type of a loss function
      Returns:
      instance of the current builder
    • randomSeed

      public FeedForwardNetwork.Builder randomSeed(long seed)
      Initializes random number generator with the specified seed in order to get same random number sequences used for weights initialization. Specifying this value enables getting same/repeatable initialization.
      Parameters:
      seed -
      Returns:
      instance of the current builder
    • build

      public FeedForwardNetwork build()
      Builds an instance of FeedForwardNetwork with settings specified in this builder.
      Returns:
      an instance of the FeedForwardNetwork created by this builder