Package deepnetts.net
Class FeedForwardNetwork.Builder
java.lang.Object
deepnetts.net.FeedForwardNetwork.Builder
- Enclosing class:
FeedForwardNetwork
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddFullyConnectedLayer
(int layerWidth) Adds to the network a fully connected layer with specified width and Relu activation function by default.addFullyConnectedLayer
(int layerWidth, ActivationType activationType) Adds fully connected addLayer with specified width and activation function to the network.addHiddenFullyConnectedLayers
(int... layerWidths) Adds to the network several hidden fully connected layers with specified widths and default hidden activation function by default.addHiddenFullyConnectedLayers
(ActivationType activationType, int... layerWidths) Adds fully connected hidden layers with widths given in layerWidths param and given activation function type.addInputLayer
(int layerWidth) Adds input layer with the specified layerWidth (number of inputs) to the network.addInputLayer
(int layerWidth, int batchSize) addLayer
(AbstractLayer layer) Adds custom layer to this network (which inherits from AbstractLayer)addOutputLayer
(int width, ActivationType activationType) Adds output layer to the neural network with specified width (number of outputs) and activation function type.build()
Builds an instance of FeedForwardNetwork with settings specified in this builder.hiddenActivationFunction
(ActivationType activationType) Sets default type of the activation function to use for all hidden layers in the network.lossFunction
(LossType lossType) Sets loss function to be used by created neural network.randomSeed
(long seed) Initializes random number generator with the specified seed in order to get same random number sequences used for weights initialization.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
addInputLayer
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
-
addFullyConnectedLayer
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
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 addactivationType
- 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 layerslayerWidths
- widths of the hidden layers- Returns:
-
addLayer
Adds custom layer to this network (which inherits from AbstractLayer)- Parameters:
layer
-- Returns:
- builder instance
-
addOutputLayer
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 outputsactivationType
- type of the activation function to use in output layer- Returns:
- builder instance
-
lossFunction
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
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
Builds an instance of FeedForwardNetwork with settings specified in this builder.- Returns:
- an instance of the FeedForwardNetwork created by this builder
-