public class Dropout extends ParameterBlock
The idea of dropout itself was proposed in 2014, with the purpose of improving the performance of large networks due to co-adaptation, where some connections are stronger and learned more while other connections become weaker and loses their impact on the prediction, resulting in network overfitting. It was also created as an alternative for costly networks, such as large or ensemble networks, by removing several units, hence creating different thinned network architectures and simulates multiple networks within a single network, greatly reducing the computation cost.
Dropout is recommended to be used when one is trying to optimize an overfitting network or when large dataset is available. It is still quite commonly used in many publications due to its generalization capability. However, using dropout may not prevent overfitting due to variation and limited size of the dataset, and it is reported that dropout layer increases training time by 2-3 times since different simulated multiple networks are trained for each iteration, thus resulting in noisy parameter updates.
| Modifier and Type | Class and Description |
|---|---|
static class |
Dropout.Builder
|
inputNames, inputShapes| Modifier and Type | Method and Description |
|---|---|
static Dropout.Builder |
builder()
Creates a builder to build a
Dropout. |
NDList |
forward(ParameterStore parameterStore,
NDList inputs,
boolean training,
ai.djl.util.PairList<java.lang.String,java.lang.Object> params)
Applies the operating function of the block once.
|
java.util.List<Parameter> |
getDirectParameters()
Returns a list of all the direct parameters of the block.
|
Shape[] |
getOutputShapes(NDManager manager,
Shape[] inputShapes)
Returns the expected output shapes of the block for the specified input shapes.
|
Shape |
getParameterShape(java.lang.String name,
Shape[] inputShapes)
Returns the shape of the specified direct parameter of this block given the shapes of the
input to the block.
|
void |
loadParameters(NDManager manager,
java.io.DataInputStream is)
Loads the parameters from the given input stream.
|
void |
saveParameters(java.io.DataOutputStream os)
Writes the parameters of the block to the given outputStream.
|
getChildren, initialize, toStringbeforeInitialize, cast, clear, describeInput, getParameters, isInitialized, readInputShapes, saveInputShapes, setInitializer, setInitializerclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforward, validateLayoutpublic NDList forward(ParameterStore parameterStore, NDList inputs, boolean training, ai.djl.util.PairList<java.lang.String,java.lang.Object> params)
parameterStore - the parameter storeinputs - the input NDListtraining - true for a training forward passparams - optional parameterspublic Shape[] getOutputShapes(NDManager manager, Shape[] inputShapes)
manager - an NDManagerinputShapes - the shapes of the inputspublic java.util.List<Parameter> getDirectParameters()
Parameterpublic Shape getParameterShape(java.lang.String name, Shape[] inputShapes)
name - the name of the parameterinputShapes - the shapes of the input to the blockpublic void saveParameters(java.io.DataOutputStream os)
throws java.io.IOException
os - the outputstream to save the parameters tojava.io.IOException - if an I/O error occurspublic void loadParameters(NDManager manager, java.io.DataInputStream is) throws java.io.IOException, MalformedModelException
manager - an NDManager to create the parameter arraysis - the inputstream that stream the parameter valuesjava.io.IOException - if an I/O error occursMalformedModelException - if the model file is corrupted or unsupportedpublic static Dropout.Builder builder()
Dropout.