org.encog.neural.freeform

## Class FreeformNetwork

- java.lang.Object
- - org.encog.ml.BasicML
  - - org.encog.neural.freeform.FreeformNetwork

- All Implemented Interfaces:
    Serializable, Cloneable, MLClassification, MLContext, MLEncodable, MLError, MLInput, MLInputOutput, MLMethod, MLOutput, MLProperties, MLRegression, MLResettable

      public class FreeformNetwork
      extends BasicML
      implements MLContext, Cloneable, MLRegression, MLEncodable, MLResettable, MLClassification, MLError

  Implements a freefrom neural network. A freeform neural network can represent much more advanced structures than the flat networks that the Encog BasicNetwork implements. However, while freeform networks are more advanced than the BasicNetwork, they are also much slower. Freeform networks allow just about any neuron to be connected to another neuron. You can have neuron layers if you want, but they are not required.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FreeformNetwork()` Default constructor.
    `FreeformNetwork(BasicNetwork network)` Craete a freeform network from a basic network.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `double` | `calculateError(MLDataSet data)` Calculate the error of the ML method, given a dataset.
    `int` | `classify(MLData input)` Classify the input into a group.
    `void` | `clearContext()` Clear the context.
    `Object` | `clone()` Return a clone of this neural network.
    `MLData` | `compute(MLData input)` Compute regression.
    `void` | `connectLayers(FreeformLayer source, FreeformLayer target)` Connect two layers.
    `void` | `ConnectLayers(FreeformLayer source, FreeformLayer target, ActivationFunction theActivationFunction)` Connect two layers, assume bias activation of 1.0 and non-recurrent connection.
    `void` | `connectLayers(FreeformLayer source, FreeformLayer target, ActivationFunction theActivationFunction, double biasActivation, boolean isRecurrent)` Connect two layers.
    `FreeformLayer` | `createContext(FreeformLayer source, FreeformLayer target)` Create a context connection, such as those used by Jordan/Elmann.
    `static FreeformNetwork` | `createElman(int input, int hidden1, int output, ActivationFunction af)` Construct an Elmann recurrent neural network.
    `static FreeformNetwork` | `createFeedforward(int input, int hidden1, int hidden2, int output, ActivationFunction af)` Create a feedforward freeform neural network.
    `FreeformLayer` | `createInputLayer(int neuronCount)` Create the input layer.
    `FreeformLayer` | `createLayer(int neuronCount)` Create a hidden layer.
    `FreeformLayer` | `createOutputLayer(int neuronCount)` Create the output layer.
    `void` | `decodeFromArray(double[] encoded)` Decode an array to this object.
    `int` | `encodedArrayLength()`
    `void` | `encodeToArray(double[] encoded)` Encode the object to the specified array.
    `int` | `getInputCount()`
    `int` | `getOutputCount()`
    `FreeformLayer` | `getOutputLayer()`
    `void` | `performConnectionTask(ConnectionTask task)` Perform the specified connection task.
    `void` | `performNeuronTask(NeuronTask task)` Perform the specified neuron task.
    `void` | `reset()` Reset the weights.
    `void` | `reset(int seed)` Reset the weights with a seed.
    `void` | `tempTrainingAllocate(int neuronSize, int connectionSize)` Allocate temp training space.
    `void` | `tempTrainingClear()` Clear the temp training data.
    `void` | `updateContext()` Update context.
    `void` | `updateProperties()` Update any objeccts when a property changes.

    - ### Methods inherited from class org.encog.ml.BasicML

      `getProperties, getPropertyDouble, getPropertyLong, getPropertyString, setProperty, setProperty, setProperty`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FreeformNetwork

          public FreeformNetwork()

      Default constructor. Typically should not be directly used.

    - #### FreeformNetwork

          public FreeformNetwork(BasicNetwork network)

      Craete a freeform network from a basic network.
      Parameters:
        `network` - The basic network to use.

  - ### Method Detail

    - #### createElman

          public static FreeformNetwork createElman(int input,
                                    int hidden1,
                                    int output,
                                    ActivationFunction af)

      Construct an Elmann recurrent neural network.
      Parameters:
        `input` - The input count.
        `hidden1` - The hidden count.
        `output` - The output count.
        `af` - The activation function.
      Returns:
        The newly created network.

    - #### createFeedforward

          public static FreeformNetwork createFeedforward(int input,
                                          int hidden1,
                                          int hidden2,
                                          int output,
                                          ActivationFunction af)

      Create a feedforward freeform neural network.
      Parameters:
        `input` - The input count.
        `hidden1` - The first hidden layer count, zero if none.
        `hidden2` - The second hidden layer count, zero if none.
        `output` - The output count.
        `af` - The activation function.
      Returns:
        The newly crated network.

    - #### calculateError

          public double calculateError(MLDataSet data)

      Calculate the error of the ML method, given a dataset.
      Specified by:
        `calculateError` in interface `MLError`
      Parameters:
        `data` - The dataset.
      Returns:
        The error.

    - #### classify

          public int classify(MLData input)

      Classify the input into a group.
      Specified by:
        `classify` in interface `MLClassification`
      Parameters:
        `input` - The input data to classify.
      Returns:
        The group that the data was classified into.

    - #### clearContext

          public void clearContext()

      Clear the context.
      Specified by:
        `clearContext` in interface `MLContext`

    - #### clone

          public Object clone()

      Return a clone of this neural network. Including structure, weights and bias values. This is a deep copy.
      Overrides:
        `clone` in class `Object`
      Returns:
        A cloned copy of the neural network.

    - #### compute

          public MLData compute(MLData input)

      Compute regression.
      Specified by:
        `compute` in interface `MLRegression`
      Parameters:
        `input` - The input data.
      Returns:
        The output data.

    - #### connectLayers

          public void connectLayers(FreeformLayer source,
                           FreeformLayer target)

      Connect two layers. These layers will be connected with a TANH activation function in a non-recurrent way. A bias activation of 1.0 will be used, if needed.
      Parameters:
        `source` - The source layer.
        `target` - The target layer.

    - #### connectLayers

          public void connectLayers(FreeformLayer source,
                           FreeformLayer target,
                           ActivationFunction theActivationFunction,
                           double biasActivation,
                           boolean isRecurrent)

      Connect two layers.
      Parameters:
        `source` - The source layer.
        `target` - The target layer.
        `theActivationFunction` - The activation function to use.
        `biasActivation` - The bias activation to use.
        `isRecurrent` - True, if this is a recurrent connection.

    - #### ConnectLayers

          public void ConnectLayers(FreeformLayer source,
                           FreeformLayer target,
                           ActivationFunction theActivationFunction)

      Connect two layers, assume bias activation of 1.0 and non-recurrent connection.
      Parameters:
        `source` - The source layer.
        `target` - The target layer.
        `theActivationFunction` - The activation function.

    - #### createContext

          public FreeformLayer createContext(FreeformLayer source,
                                    FreeformLayer target)

      Create a context connection, such as those used by Jordan/Elmann.
      Parameters:
        `source` - The source layer.
        `target` - The target layer.
      Returns:
        The newly created context layer.

    - #### createInputLayer

          public FreeformLayer createInputLayer(int neuronCount)

      Create the input layer.
      Parameters:
        `neuronCount` - The input neuron count.
      Returns:
        The newly created layer.

    - #### createLayer

          public FreeformLayer createLayer(int neuronCount)

      Create a hidden layer.
      Parameters:
        `neuronCount` - The neuron count.
      Returns:
        The newly created layer.

    - #### createOutputLayer

          public FreeformLayer createOutputLayer(int neuronCount)

      Create the output layer.
      Parameters:
        `neuronCount` - The neuron count.
      Returns:
        The newly created output layer.

    - #### decodeFromArray

          public void decodeFromArray(double[] encoded)

      Decode an array to this object.
      Specified by:
        `decodeFromArray` in interface `MLEncodable`
      Parameters:
        `encoded` - The encoded array.

    - #### encodedArrayLength

          public int encodedArrayLength()

      Specified by:
        `encodedArrayLength` in interface `MLEncodable`
      Returns:
        The length of an encoded array.

    - #### encodeToArray

          public void encodeToArray(double[] encoded)

      Encode the object to the specified array.
      Specified by:
        `encodeToArray` in interface `MLEncodable`
      Parameters:
        `encoded` - The array.

    - #### getInputCount

          public int getInputCount()

      Specified by:
        `getInputCount` in interface `MLInput`
      Returns:
        The input.

    - #### getOutputCount

          public int getOutputCount()

      Specified by:
        `getOutputCount` in interface `MLOutput`
      Returns:
        The output count.

    - #### getOutputLayer

          public FreeformLayer getOutputLayer()

      Returns:
        The output layer.

    - #### performConnectionTask

          public void performConnectionTask(ConnectionTask task)

      Perform the specified connection task. This task will be performed over all connections.
      Parameters:
        `task` - The connection task.

    - #### performNeuronTask

          public void performNeuronTask(NeuronTask task)

      Perform the specified neuron task. This task will be executed over all neurons.
      Parameters:
        `task` -

    - #### reset

          public void reset()

      Reset the weights.
      Specified by:
        `reset` in interface `MLResettable`

    - #### reset

          public void reset(int seed)

      Reset the weights with a seed.
      Specified by:
        `reset` in interface `MLResettable`
      Parameters:
        `seed` - The seed value.

    - #### tempTrainingAllocate

          public void tempTrainingAllocate(int neuronSize,
                                  int connectionSize)

      Allocate temp training space.
      Parameters:
        `neuronSize` - The number of elements to allocate on each neuron.
        `connectionSize` - The number of elements to allocate on each connection.

    - #### tempTrainingClear

          public void tempTrainingClear()

      Clear the temp training data.

    - #### updateContext

          public void updateContext()

      Update context.

    - #### updateProperties

          public void updateProperties()

      Update any objeccts when a property changes.
      Specified by:
        `updateProperties` in interface `MLProperties`
      Specified by:
        `updateProperties` in class `BasicML`

Copyright © 2014. All Rights Reserved.