Class Mlp

  • All Implemented Interfaces:
    ai.djl.nn.Block

    public class Mlp
    extends ai.djl.nn.SequentialBlock
    Multilayer Perceptron (MLP) NeuralNetworks.

    A multilayer perceptron (MLP) is a feedforward artificial neural network that generates a set of outputs from a set of inputs. An MLP is characterized by several layers of input nodes connected as a directed graph between the input and output layers. MLP uses backpropogation for training the network.

    MLP is widely used for solving problems that require supervised learning as well as research into computational neuroscience and parallel distributed processing. Applications include speech recognition, image recognition and machine translation.

    See Also:
    The D2L chapters on MLPs
    • Field Summary

      • Fields inherited from class ai.djl.nn.AbstractBlock

        children, parameters
      • Fields inherited from class ai.djl.nn.AbstractBaseBlock

        inputNames, inputShapes, version
    • Constructor Summary

      Constructors 
      Constructor Description
      Mlp​(int input, int output, int[] hidden)
      Create an MLP NeuralNetwork using RELU.
      Mlp​(int input, int output, int[] hidden, java.util.function.Function<ai.djl.ndarray.NDList,​ai.djl.ndarray.NDList> activation)
      Create an MLP NeuralNetwork.
    • Method Summary

      • Methods inherited from class ai.djl.nn.SequentialBlock

        add, add, addAll, addAll, addSingleton, forwardInternal, forwardInternal, getOutputShapes, initializeChildBlocks, loadMetadata, removeLastBlock, replaceLastBlock, toString
      • Methods inherited from class ai.djl.nn.AbstractBlock

        addChildBlock, addParameter, getChildren, getDirectParameters
      • Methods inherited from class ai.djl.nn.AbstractBaseBlock

        beforeInitialize, cast, clear, describeInput, forward, forward, getParameters, initialize, isInitialized, loadParameters, prepare, readInputShapes, saveInputShapes, saveMetadata, saveParameters, setInitializer, setInitializer, setInitializer
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface ai.djl.nn.Block

        forward, freezeParameters
    • Constructor Detail

      • Mlp

        public Mlp​(int input,
                   int output,
                   int[] hidden)
        Create an MLP NeuralNetwork using RELU.
        Parameters:
        input - the size of the input vector
        output - the size of the output vector
        hidden - the sizes of all of the hidden layers
      • Mlp

        public Mlp​(int input,
                   int output,
                   int[] hidden,
                   java.util.function.Function<ai.djl.ndarray.NDList,​ai.djl.ndarray.NDList> activation)
        Create an MLP NeuralNetwork.
        Parameters:
        input - the size of the input vector
        output - the size of the output vector
        hidden - the sizes of all of the hidden layers
        activation - the activation function to use