Package me.yixqiao.jlearn.layers
Class Dense
- java.lang.Object
-
- me.yixqiao.jlearn.layers.Layer
-
- me.yixqiao.jlearn.layers.Dense
-
- All Implemented Interfaces:
java.io.Serializable
public class Dense extends Layer
Basic fully-connected layer.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Dense(int outSize, Activation activation)Create a new dense layer.Dense(int outSize, Activation activation, Initializer init)Create a new dense layer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LayercloneLayer()Clone the layer, including weights and biases.LayercloneSettings()Clone the settings.MatrixforwardPropagate(Matrix x)Forward propagate a batch of input.ActivationgetActivation()Get the activation of the layer.MatrixgetErrors(Matrix prevErrors)Get backpropagated errors.MatrixgetErrorsExpected(Matrix y)Get errors from output layer.intgetOutSize()Get the output size of the layer.voidinitLayer(int inSize, Activation prevActivation)Create the layer.voidsetOptimizers(Optimizer wOptimizer, Optimizer bOptimizer)Set optimizers for training the layer.java.lang.StringtoString()Get a string representation.voidupdate(Matrix errors)Update the layer after calculating errors.
-
-
-
Constructor Detail
-
Dense
public Dense(int outSize, Activation activation)Create a new dense layer.- Parameters:
outSize- size of outputactivation- activation to use
-
Dense
public Dense(int outSize, Activation activation, Initializer init)Create a new dense layer.- Parameters:
outSize- size of outputactivation- activation to useinit- initialization method
-
-
Method Detail
-
setOptimizers
public void setOptimizers(Optimizer wOptimizer, Optimizer bOptimizer)
Description copied from class:LayerSet optimizers for training the layer.- Specified by:
setOptimizersin classLayer- Parameters:
wOptimizer- optimizer for weightsbOptimizer- optimizer for biases
-
initLayer
public void initLayer(int inSize, Activation prevActivation)Description copied from class:LayerCreate the layer.
-
getActivation
public Activation getActivation()
Description copied from class:LayerGet the activation of the layer.- Specified by:
getActivationin classLayer- Returns:
- the activation object
-
getOutSize
public int getOutSize()
Description copied from class:LayerGet the output size of the layer.- Specified by:
getOutSizein classLayer- Returns:
- the output size
-
forwardPropagate
public Matrix forwardPropagate(Matrix x)
Description copied from class:LayerForward propagate a batch of input.- Specified by:
forwardPropagatein classLayer- Parameters:
x- input matrix- Returns:
- output matrix
-
getErrors
public Matrix getErrors(Matrix prevErrors)
Description copied from class:LayerGet backpropagated errors.
-
getErrorsExpected
public Matrix getErrorsExpected(Matrix y)
Description copied from class:LayerGet errors from output layer.- Specified by:
getErrorsExpectedin classLayer- Parameters:
y- expected outputs- Returns:
- matrix of errors
-
update
public void update(Matrix errors)
Description copied from class:LayerUpdate the layer after calculating errors.
-
toString
public java.lang.String toString()
Description copied from class:LayerGet a string representation.
-
cloneSettings
public Layer cloneSettings()
Description copied from class:LayerClone the settings.This will return a layer with the same size and activation, but with randomly initialized weights and biases.
- Specified by:
cloneSettingsin classLayer- Returns:
- the clone
-
cloneLayer
public Layer cloneLayer()
Description copied from class:LayerClone the layer, including weights and biases.- Specified by:
cloneLayerin classLayer- Returns:
- the clone
-
-