bodhidharma.classifiers.feedforward_neural_networks
Class LinkedNodes

java.lang.Object
  extended by bodhidharma.classifiers.feedforward_neural_networks.LinkedNodes

public class LinkedNodes
extends java.lang.Object

Objects of this class represent complete backprop neural networks. LinkedNodes objects link the node objects together and allow them to interact with one another. LinkedNodes objects are controlled by FeedForwardNeuralNetwork objects. Adjustable learning rates and momentums are permitted. An arbitrary number of input nodes, hidden nodes and output nodes are permitted.

Only allows perceptrons or neural networks with one layer of hidden nodes. Only limited error checking is implemented. It is assumed that correct input is passed to the methods.

Author:
Cory McKay

Constructor Summary
LinkedNodes(double learning_rate, double momentum, int inputs, int hidden, int outputs, double[] weights)
          Use this constructor when loading a pre-existing network.
LinkedNodes(double learning_rate, double momentum, int inputs, int hidden, int outputs, double min_w, double max_w)
          Use this constructor when generating a network from scratch.
 
Method Summary
 double get_error(double[] sample_input, double[] corresponding_output)
          Returns the sum-of-squared-error for given data set
 double[] get_output(double[] input_values)
          Returns the array of values output at the output nodes corresponding to input_values
 java.lang.String get_weight_string()
          Returns a string contating a vertical list of learning rate, momentum, number of input nodes, number of hidden nodes, number of output nodes and all weights (hidden nodes followed by output nodes).
 java.lang.String getHiddenNodesCount()
          Return the number of hidden nodes
 java.lang.String getLearningRate()
          Return the learning rate
 double getLearningRateValue()
          Returns the learning rate used by the network
 java.lang.String getMomentum()
          Return the momentum
 double getMomentumValue()
          Returns the momentum used by the network
 int getNumberOfHiddenUnits()
          Returns the number of hidden units in the network
 int getNumberOfInputUnits()
          Returns the number of input units in the network
 int getNumberOfOutputUnits()
          Returns the number of output units in the network
 double[] getWeights()
          Returns the weights of all of the links in the network, starting with the hidden nodes and movin on to the output nodes.
 java.lang.String print_network()
          Returns a string containting the current inputs, weights and values of the network nodes.
 double training_iteration(double[] input_values, double[] desired_values)
          Goes through one iteration of training to update all weights once, given the desired output values for the given input_values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkedNodes

public LinkedNodes(double learning_rate,
                   double momentum,
                   int inputs,
                   int hidden,
                   int outputs,
                   double min_w,
                   double max_w)
Use this constructor when generating a network from scratch.

Parameters:
learning_rate - The learning rate neural network parameter used during training.
momentum - The momentum neural network parameter used during training.
inputs - The number of input nodes.
hidden - The number of hidden nodes.
outputs - The number of output nodes.
min_w - The minimum possible value for the randomly generated initial weights.
max_w - The maximum possible value for the randomly generated initial weights.

LinkedNodes

public LinkedNodes(double learning_rate,
                   double momentum,
                   int inputs,
                   int hidden,
                   int outputs,
                   double[] weights)
Use this constructor when loading a pre-existing network.

Parameters:
learning_rate - The learning rate neural network parameter used during training.
momentum - The momentum neural network parameter used during training.
inputs - The number of input nodes.
hidden - The number of hidden nodes.
outputs - The number of output nodes.
weights - Contains the weights of the hidden nodes (if any) followed by those of the output nodes.
Method Detail

get_output

public double[] get_output(double[] input_values)
Returns the array of values output at the output nodes corresponding to input_values


training_iteration

public double training_iteration(double[] input_values,
                                 double[] desired_values)
Goes through one iteration of training to update all weights once, given the desired output values for the given input_values. Returns the sum-of-squared-error between the given desired output values and the results of the network AFTER the training iteration has been completed.


get_error

public double get_error(double[] sample_input,
                        double[] corresponding_output)
Returns the sum-of-squared-error for given data set


getLearningRateValue

public double getLearningRateValue()
Returns the learning rate used by the network


getMomentumValue

public double getMomentumValue()
Returns the momentum used by the network


getNumberOfInputUnits

public int getNumberOfInputUnits()
Returns the number of input units in the network


getNumberOfHiddenUnits

public int getNumberOfHiddenUnits()
Returns the number of hidden units in the network


getNumberOfOutputUnits

public int getNumberOfOutputUnits()
Returns the number of output units in the network


getWeights

public double[] getWeights()
Returns the weights of all of the links in the network, starting with the hidden nodes and movin on to the output nodes.


print_network

public java.lang.String print_network()
Returns a string containting the current inputs, weights and values of the network nodes. Used during debugging


get_weight_string

public java.lang.String get_weight_string()
Returns a string contating a vertical list of learning rate, momentum, number of input nodes, number of hidden nodes, number of output nodes and all weights (hidden nodes followed by output nodes).


getLearningRate

public java.lang.String getLearningRate()
Return the learning rate


getMomentum

public java.lang.String getMomentum()
Return the momentum


getHiddenNodesCount

public java.lang.String getHiddenNodesCount()
Return the number of hidden nodes