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 Layer
cloneLayer()
Clone the layer, including weights and biases.Layer
cloneSettings()
Clone the settings.Matrix
forwardPropagate(Matrix x)
Forward propagate a batch of input.Activation
getActivation()
Get the activation of the layer.Matrix
getErrors(Matrix prevErrors)
Get backpropagated errors.Matrix
getErrorsExpected(Matrix y)
Get errors from output layer.int
getOutSize()
Get the output size of the layer.void
initLayer(int inSize, Activation prevActivation)
Create the layer.void
setOptimizers(Optimizer wOptimizer, Optimizer bOptimizer)
Set optimizers for training the layer.java.lang.String
toString()
Get a string representation.void
update(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:Layer
Set optimizers for training the layer.- Specified by:
setOptimizers
in classLayer
- Parameters:
wOptimizer
- optimizer for weightsbOptimizer
- optimizer for biases
-
initLayer
public void initLayer(int inSize, Activation prevActivation)
Description copied from class:Layer
Create the layer.
-
getActivation
public Activation getActivation()
Description copied from class:Layer
Get the activation of the layer.- Specified by:
getActivation
in classLayer
- Returns:
- the activation object
-
getOutSize
public int getOutSize()
Description copied from class:Layer
Get the output size of the layer.- Specified by:
getOutSize
in classLayer
- Returns:
- the output size
-
forwardPropagate
public Matrix forwardPropagate(Matrix x)
Description copied from class:Layer
Forward propagate a batch of input.- Specified by:
forwardPropagate
in classLayer
- Parameters:
x
- input matrix- Returns:
- output matrix
-
getErrors
public Matrix getErrors(Matrix prevErrors)
Description copied from class:Layer
Get backpropagated errors.
-
getErrorsExpected
public Matrix getErrorsExpected(Matrix y)
Description copied from class:Layer
Get errors from output layer.- Specified by:
getErrorsExpected
in classLayer
- Parameters:
y
- expected outputs- Returns:
- matrix of errors
-
update
public void update(Matrix errors)
Description copied from class:Layer
Update the layer after calculating errors.
-
toString
public java.lang.String toString()
Description copied from class:Layer
Get a string representation.
-
cloneSettings
public Layer cloneSettings()
Description copied from class:Layer
Clone the settings.This will return a layer with the same size and activation, but with randomly initialized weights and biases.
- Specified by:
cloneSettings
in classLayer
- Returns:
- the clone
-
cloneLayer
public Layer cloneLayer()
Description copied from class:Layer
Clone the layer, including weights and biases.- Specified by:
cloneLayer
in classLayer
- Returns:
- the clone
-
-