Package com.jml.neural_network.layers
Class Dropout
java.lang.Object
com.jml.neural_network.layers.Dropout
- All Implemented Interfaces:
BaseLayer
A dropout layer. This layer has a probability of dropping (zeroing out) each element during the forward pass. This is
only done during training. Dropout layers will not be used when making predictions with the final model.
Dropout is an effective form of regularization. In addition, the outputs of this layer are scaled by 1/(1-p) where p is the probability of dropping an element of the layer.
Dropout is an effective form of regularization. In addition, the outputs of this layer are scaled by 1/(1-p) where p is the probability of dropping an element of the layer.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlinalg.Matrix
back(linalg.Matrix upstreamGrad)
Computes backward pass for layer.linalg.Matrix
forward(linalg.Matrix forwardIn)
Feeds the inputs through the layer.Constructs a string containing this all details of the model pertinent for saving the model to a file.int
getInDim()
Gets the input dimension of this layer.int
Gets the output dimension of this layer.inspect()
Gets the details of this layer as a String.void
updateInDim(int inDim)
Updates the input dimension for the layer.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jml.neural_network.layers.BaseLayer
getParams, getUpdates, resetGradients, setParams
-
Field Details
-
LAYER_TYPE
- See Also:
- Constant Field Values
-
-
Constructor Details
-
Dropout
public Dropout(double p)Constructs a dropout layer for a neural network.
Note: this constructor infers the input dimension from the previous layer in the network. Thus, it cannot be used as the first layer of the neural network. For the first layer useDropout(int, double)
to specify the input dimension.- Parameters:
p
- The probability of an element being zeroed.
-
Dropout
public Dropout(int inDim, double p)Constructs a dropout layer for a neural network.- Parameters:
inDim
- Input dimension of the layer.p
- The probability of an element being zeroed.
-
-
Method Details
-
forward
public linalg.Matrix forward(linalg.Matrix forwardIn)Feeds the inputs through the layer. Each input will be scaled by1/(1-p)
and have a probability,p
, of being zeroed or "dropped." -
back
public linalg.Matrix back(linalg.Matrix upstreamGrad)Description copied from interface:BaseLayer
Computes backward pass for layer. -
getInDim
public int getInDim()Gets the input dimension of this layer. -
getOutDim
public int getOutDim()Gets the output dimension of this layer. -
updateInDim
public void updateInDim(int inDim)Updates the input dimension for the layer.
WARNING: This will zero any weight values the layer may currently be holding.- Specified by:
updateInDim
in interfaceBaseLayer
- Parameters:
inDim
- New input size for the layer.
-
inspect
Gets the details of this layer as a String. -
getDetails
Constructs a string containing this all details of the model pertinent for saving the model to a file.- Specified by:
getDetails
in interfaceBaseLayer
- Returns:
- A string containing all information, including trainable parameters, needed to recreate the layer.
-