NeuralNetwork class

This is the documentation for the python NeuralNetwork class and its methods in the OpenNN python module.

This class represents the concept of neural network in the OpenNN library. A neural network here is defined as a multilayer perceptron extended with a scaling layer, an unscaling layer, a bounding layer and a probabilistic layer. This neural network is used to span a function space for the variational problem at hand.

Initialization methods

  • NeuralNetwork()
  • Default initialization method.

  • NeuralNetwork(MultilayerPerceptron)

    Multilayer Perceptron initialization method. It creates a neural network object from a given multilayer perceptron. The rest of pointers are initialized to nullptr. This initialization method also initializes the rest of class members to their default values.

  • NeuralNetwork(new_multilayer_perceptron_architecture)

    Multilayer perceptron architecture initialization method. It creates a neural network object with a multilayer perceptron given by its architecture. This initialization method allows an arbitrary deep learning architecture. The rest of pointers are initialized to nullptr. This initialization method also initializes the rest of class members to their default values.

    • new_multilayer_perceptron_architecture Vector with the number of inputs and the numbers of perceptrons in each layer. The size of this vector must be equal to one plus the number of layers.

  • NeuralNetwork(new_inputs_number, new_perceptrons_number)

    One layer initialization method. It creates a one-layer perceptron object. The number of independent parameters is set to zero. The multilayer perceptron parameters are initialized at random.

    • new_inputs_number Number of inputs in the layer.
    • new_perceptrons_number Number of perceptrons in the layer.

  • NeuralNetwork(new_inputs_number, new_hidden_perceptron_number, new_outputs_number)

    Two layers initialization method. It creates a neural network object with a two layers perceptron. The rest of pointers of this object are initialized to nullptr. The other members are initialized to their default values.

    • new_inputs_number Number of inputs in the multilayer perceptron.
    • new_hidden_perceptrons_number Number of neurons in the hidden layer of the multilayer perceptron.
    • new_output_perceptrons_number Number of outputs neurons.

  • NeuralNetwork(file_name)

    File initialization method. It creates a neural network object by loading its members from an XML-type file. Please be careful with the format of that file, which is specified in the OpenNN manual.

    • file_name Name of neural network file.

  • NeuralNetwork(other_neural_network)

    Copy initialization method. It creates a copy of an existing neural network object.

    • other_neural_network Neural network object to be copied.
  • General methods
    • inputs()
    • Returns a pointer to the inputs object composing this neural network.

    • outputs()
    • Returns a pointer to the outputs object composing this neural network.

    • construct_scaling_layer()
    • This method constructs a scaling layer within the neural network. The size of the scaling layer is the number of inputs in the multilayer perceptron.

    • get_scaling_layer()
    • Returns a pointer to the scaling layer composing this neural network.

    • construct_unscaling_layer()
    • This method constructs an unscaling layer within the neural network. The size of the unscaling layer is the number of outputs in the multilayer perceptron.

    • get_unscaling_layer()
    • Returns a pointer to the unscaling layer composing this neural network.

    • write_expression()
    • Writes the mathematical expression of the model.

    • write_expression_python()
    • Writes the mathematical expression of the model in Python format.

    • save_parameters(file_name)

      Saves to a data file the parameters of a neural network object.

      • file_name Name of parameters data file.

    • load_parameters(file_name)

      Loads the multilayer perceptron parameters from a data file. The format of this file is just a sequence of numbers.

      • file_name Name of parameters data file.

    • save_expression(file_name)

      Saves the mathematical expression represented by the neural network to a text file.

      • file_name Name of expression text file.

    • save_expression_python(file_name)

      Saves the python function of the expression represented by the neural network to a text file.

      • file_name Name of expression text file.

    • save_expression_R(file_name)

      Saves the R function of the expression represented by the neural network to a text file.

      • file_name Name of expression text file.

    • save(file_name)

      Saves to a XML file the members of a neural network object.

      • file_name Name of neural network XML file.

    • load(file_name)

      Loads from a XML file the members for this neural network object. Please mind about the file format, which is specified in the User's Guide.

      • file_name Name of neural network XML file.

    • calculate_outputs(inputs)

      Calculates the outputs vector from the multilayer perceptron in response to an inputs vector.

      • inputs Set of inputs to the neural network.

    • parameters_norm()
    • Returns the norm of the vector of parameters.

    • initialize_random()
    • Initializes the neural network at random. This is useful for testing purposes.

    • randomize_parameters_normal()
    • Initializes all the parameters in the neural newtork(biases and synaptic weiths + independent parameters) at random with values chosen from a normal distribution with mean 0 and standard deviation 1.

    • randomize_parameters_uniform()
    • Initializes all the parameters in the newtork(biases and synaptic weiths + independent parameters) at random with values comprised between -1 and +1.