Package deepnetts.net
Class ConvolutionalNetwork.Builder
java.lang.Object
deepnetts.net.ConvolutionalNetwork.Builder
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddConvolutionalLayer
(int channelNum) Adds a convolutional layer with the given number of channels(filters), with default 3x3 filter size and default activation function.addConvolutionalLayer
(int channelNum, int filterSize) Adds a convolutional layer with the given number of channels(filters), with given filter size (same width and height) and default activation function.addConvolutionalLayer
(int channelNum, int filterWidth, int filterHeight) Adds a convolutional layer with the given number of channels(filters), with given width and height of convolutional filter and default type of activation function.addConvolutionalLayer
(int channelNum, int filterWidth, int filterHeight, int stride) Adds a convolutional layer with the given width and height of convolutional filters, given number of channels(filters) and stride(filter step), and default type of activation function.addConvolutionalLayer
(int channelNum, int filterWidth, int filterHeight, int stride, ActivationType activationType) Adds a convolutional layer with the given width and height of convolutional filters, given number of channels(filters) and stride(filter step), and given type of activation function.addConvolutionalLayer
(int channelNum, int filterSize, ActivationType activationType) Adds a convolutional layer with the given number of channels(filters), with given filter size (same width and height) and given type of activation function.addConvolutionalLayer
(int channelNum, ActivationType activationType) Adds a convolutional layer with the given number of channels(filters), with given activation function type and default 3x3 filter size.addConvolutionalLayer
(int channelNum, Filter filter) Adds a convolutional layer with the given number of channels(filters), with given settings of a convolutional filter and default type of activation function.addConvolutionalLayer
(int channelNum, Filter filter, ActivationType activationType) Adds a convolutional layer with the given number of channels(filters), with given settings of a convolutional filter and given type of activation function.addFullyConnectedLayer
(int layerWidth) Adds fully connected layer with specified width and default activation function.addFullyConnectedLayer
(int layerWidth, ActivationType activationType) Adds fully connected layer with specified width and activation function.addInputLayer
(int width, int height) Input layer with specified width and height, and 3 channels by default.addInputLayer
(int width, int height, int channels) Input layer with specified width, height and number of channels (depth).addLayer
(AbstractLayer layer) Adds a given layer to the network.addMaxPoolingLayer
(int filterSize) addMaxPoolingLayer
(int filterSize, int stride) Adds a max pooling layer with given filter size and stride(filter step).addMaxPoolingLayer
(int filterWidth, int filterHeight, int stride) Adds a max pooling layer with given filter size and stride(filter step).Max pooling layer comes after convolutional layer and reduces the dimensions of the input received from the previous layer.Typically filter sizes of 2 are used, which effectively halves the dimensions of the input from the previous layer.addMaxPoolingLayer
(Filter filter) Adds a max pooling layer with the given filter settings.Max pooling layer comes after convolutional layer and reduces the dimensions of the input received from the previous layer.addOutputLayer
(int layerWidth, ActivationType activationType) Adds output layer to the neural network with specified width (number of outputs) and activation function type.addOutputLayer
(int layerWidth, Class<? extends OutputLayer> clazz) Adds output layer to the neural network with specified width (number of outputs) and layer class.build()
Builds an instance of ConvolutionalNetwork 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
Input layer with specified width and height, and 3 channels by default.- Parameters:
width
-height
-- Returns:
-
addInputLayer
Input layer with specified width, height and number of channels (depth).- Parameters:
width
- width of the input Tensorheight
- height of the input Tensorchannels
- depth of the input Tensor- Returns:
- this builder
-
addFullyConnectedLayer
Adds fully connected layer with specified width and default activation function. In fully connected layer each neuron is connected to all outputs from previous layer.- Parameters:
layerWidth
- width of the layer which corresponds to the number of outputs/neurons in this layer- Returns:
- current builder instance
- See Also:
-
addFullyConnectedLayer
public ConvolutionalNetwork.Builder addFullyConnectedLayer(int layerWidth, ActivationType activationType) Adds fully connected layer with specified width and activation function. In dense layer each neuron is connected to all outputs from previous layer.- Parameters:
layerWidth
- width of the layer which corresponds to the number of outputs/neurons in this layeractivationType
- type of activation function- Returns:
- current builder instance
- See Also:
-
addOutputLayer
public ConvolutionalNetwork.Builder addOutputLayer(int layerWidth, Class<? extends OutputLayer> clazz) Adds output layer to the neural network with specified width (number of outputs) and layer class.- Parameters:
layerWidth
- width of the layer which corresponds to number of network's outputsclazz
- class of the output layer- Returns:
- builder instance
-
addOutputLayer
Adds output layer to the neural network with specified width (number of outputs) and activation function type.- Parameters:
layerWidth
- width of the layer which corresponds to number of network's outputsactivationType
- type of the activation function to use in output layer- Returns:
- builder instance
-
addConvolutionalLayer
Adds a convolutional layer with the given number of channels(filters), with default 3x3 filter size and default activation function. Each channel(filter) is capable to learn to detect a specific patern of pixels in image.- Parameters:
channelNum
- number of channels(filters) in the convolutional layer- Returns:
- builder instance
- See Also:
-
addConvolutionalLayer
public ConvolutionalNetwork.Builder addConvolutionalLayer(int channelNum, ActivationType activationType) Adds a convolutional layer with the given number of channels(filters), with given activation function type and default 3x3 filter size. Each channel(filter) is capable to learn to detect a specific patern of pixels in image.- Parameters:
channelNum
- number of channels(filters) in the convolutional layeractivationType
- type of the activation function in the convolutional layer- Returns:
- builder instance
- See Also:
-
addConvolutionalLayer
Adds a convolutional layer with the given number of channels(filters), with given filter size (same width and height) and default activation function. Each channel(filter) is capable to learn to detect a specific patern of pixels in image.- Parameters:
channelNum
- number of channels(filters) in the convolutional layerfilterSize
- size of the convolutional filter (same width and height)- Returns:
- builder instance
- See Also:
-
addConvolutionalLayer
public ConvolutionalNetwork.Builder addConvolutionalLayer(int channelNum, int filterSize, ActivationType activationType) Adds a convolutional layer with the given number of channels(filters), with given filter size (same width and height) and given type of activation function. Each channel(filter) is capable to learn to detect a specific patern of pixels in image.- Parameters:
channelNum
- number of channels(filters) in the convolutional layerfilterSize
- size of the convolutional filter (same width and height)activationType
- type of the activation function in the convolutional layer- Returns:
- builder instance
- See Also:
-
addConvolutionalLayer
public ConvolutionalNetwork.Builder addConvolutionalLayer(int channelNum, int filterWidth, int filterHeight) Adds a convolutional layer with the given number of channels(filters), with given width and height of convolutional filter and default type of activation function. Each channel(filter) is capable to learn to detect a specific patern of pixels in image.- Parameters:
channelNum
- number of channels(filters) in the convolutional layerfilterWidth
- width of a convolutional filterfilterHeight
- height of a convolutional filter- Returns:
- builder instance
- See Also:
-
addConvolutionalLayer
Adds a convolutional layer with the given number of channels(filters), with given settings of a convolutional filter and default type of activation function. Each channel(filter) is capable to learn to detect a specific patern of pixels in image.- Parameters:
channelNum
- number of channels(filters) in the convolutional layerfilter
- settings of the convolutional filter(width, height, stride, padding)- Returns:
- builder instance
- See Also:
-
addConvolutionalLayer
public ConvolutionalNetwork.Builder addConvolutionalLayer(int channelNum, int filterWidth, int filterHeight, int stride) Adds a convolutional layer with the given width and height of convolutional filters, given number of channels(filters) and stride(filter step), and default type of activation function. Each channel(filter) is capable to learn to detect a specific patern of pixels in image.- Parameters:
channelNum
- number of channels(filters)filterWidth
- width of a convolutional filterfilterHeight
- height of a convolutional filterstride
- filter stride(step)- Returns:
- builder instance
- See Also:
-
addConvolutionalLayer
public ConvolutionalNetwork.Builder addConvolutionalLayer(int channelNum, Filter filter, ActivationType activationType) Adds a convolutional layer with the given number of channels(filters), with given settings of a convolutional filter and given type of activation function. Each channel(filter) is capable to learn to detect a specific patern of pixels in image.- Parameters:
channelNum
- number of channels(filters) in the convolutional layerfilter
- settings of the convolutional filter(width, height, stride, padding)activationType
- type of the activation function in the convolutional layer- Returns:
- builder instance
- See Also:
-
addConvolutionalLayer
public ConvolutionalNetwork.Builder addConvolutionalLayer(int channelNum, int filterWidth, int filterHeight, int stride, ActivationType activationType) Adds a convolutional layer with the given width and height of convolutional filters, given number of channels(filters) and stride(filter step), and given type of activation function. Each channel(filter) is capable to learn to detect a specific patern of pixels in image.- Parameters:
channelNum
- number of channels(filters)filterWidth
- width of a convolutional filterfilterHeight
- height of a convolutional filterstride
- filter stride(step)activationType
- type of the activation function in the convolutional layer- Returns:
- builder instance
- See Also:
-
addMaxPoolingLayer
Adds a max pooling layer with given filter size and stride(filter step). Max pooling layer comes after convolutional layer and reduces the dimensions of the input received from the previous layer. Typically filter sizes of 2 are used, which effectively halves the dimensions of the input from the previous layer.- Parameters:
filterSize
- size of the max pooling filter(typically 2)stride
- filter step size - how many pixels will filter slide. Typically same as filter size for pooling layers.- Returns:
- builder instance
-
addMaxPoolingLayer
-
addMaxPoolingLayer
public ConvolutionalNetwork.Builder addMaxPoolingLayer(int filterWidth, int filterHeight, int stride) Adds a max pooling layer with given filter size and stride(filter step).Max pooling layer comes after convolutional layer and reduces the dimensions of the input received from the previous layer.Typically filter sizes of 2 are used, which effectively halves the dimensions of the input from the previous layer.- Parameters:
filterWidth
- pooling filter widthfilterHeight
- pooling filter heightstride
- filter step size which is typically same as filter size for pooling layers.- Returns:
- builder instance
-
addMaxPoolingLayer
Adds a max pooling layer with the given filter settings.Max pooling layer comes after convolutional layer and reduces the dimensions of the input received from the previous layer. Typically filter sizes of 2 are used, which effectively halves the dimensions of the input from the previous layer.- Parameters:
filter
- settings of the pooling filter(width, height, stride, padding)- Returns:
- builder instance
-
addLayer
Adds a given layer to the network.- Parameters:
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 ConvolutionalNetwork with settings specified in this builder.- Returns:
- an instance of the ConvolutionalNetwork created by this builder
-