Class MultiLayerPerceptron

java.lang.Object
edu.cmu.tetrad.search.utils.MultiLayerPerceptron

public class MultiLayerPerceptron extends Object
The MultiLayerPerceptron class represents a simple feedforward neural network with one output and support for multiple hidden layers. The network uses configurable activation functions and random initialization of weights and biases.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MultiLayerPerceptron(int inputDim, int[] hiddenLayers, Function<Double,Double> activation, double inputScale, long seed)
    Constructor to initialize a random multi-layer perceptron.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    evaluate(double[] x)
    Evaluates the MLP for a given input vector.
    static void
    main(String[] args)
    The main method serves as the entry point of the application.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MultiLayerPerceptron

      public MultiLayerPerceptron(int inputDim, int[] hiddenLayers, Function<Double,Double> activation, double inputScale, long seed)
      Constructor to initialize a random multi-layer perceptron.
      Parameters:
      inputDim - Number of input dimensions (R^n).
      hiddenLayers - Array specifying the number of neurons in each hidden layer.
      activation - Activation function (e.g., Math::tanh or Math::sin).
      inputScale - Scaling factor for the input to create bumpiness.
      seed - Random seed for reproducibility.
  • Method Details

    • main

      public static void main(String[] args)
      The main method serves as the entry point of the application. It demonstrates the usage of the MultiLayerPerceptron class by initializing a perceptron with specific parameters, processing sample input data, and outputting the computed results.
      Parameters:
      args - Command-line arguments provided to the application (not used in this implementation).
    • evaluate

      public double evaluate(double[] x)
      Evaluates the MLP for a given input vector.
      Parameters:
      x - Input vector in R^n.
      Returns:
      Output value in R.