org.knime.base.data.neural
Class Perceptron

java.lang.Object
  extended by org.knime.base.data.neural.Perceptron
Direct Known Subclasses:
InputPerceptron, SigmoidPerceptron

public abstract class Perceptron
extends Object

Abstract class defining the behaviour of a perceptron in a neural network.

Author:
Nicolas Cebron, University of Konstanz

Constructor Summary
Perceptron()
          Construct an empty perceptron (cannot be used properly unless the weights are set).
Perceptron(double[] weights)
          Construct a perceptron with given weights.
Perceptron(int nrInputs)
          Construct a perceptron with given number of weights.
 
Method Summary
abstract  double activationFunction(double in)
          Activation function.
 double evaluate(double[] in)
          Evaluates a given input for the perceptron.
 String getClassValue()
           
 double getThreshold()
          Returns the threshold.
 double getWeight(int i)
          Get weight at given position.
 double[] getWeights()
           
abstract  double output()
          Used to get the output from all input neurons.
static double random()
          Returns a randomly chosen double between -1 and 1.
static double scalarProduct(double[] x, double[] y)
          Computes the scalar Product of two vectors, represented as double arrays.
 void setClassValue(String classval)
          Allows to set a class value for a perceptron (optional).
 void setThreshold(double threshold)
          Sets the threshold.
 void setWeight(int i, double weight)
          Sets weight at given position.
 void setWeights(double[] weights)
          Set all new weights.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Perceptron

public Perceptron(int nrInputs)
Construct a perceptron with given number of weights. Weights and threshold are randomly initialized.

Parameters:
nrInputs - number of inputs for the new perceptron

Perceptron

public Perceptron()
Construct an empty perceptron (cannot be used properly unless the weights are set).


Perceptron

public Perceptron(double[] weights)
Construct a perceptron with given weights.

Parameters:
weights - weights for the new perceptron
Method Detail

getWeights

public double[] getWeights()
Returns:
weights of the perceptron

getWeight

public double getWeight(int i)
Get weight at given position.

Parameters:
i - position
Returns:
weight at position i

setWeights

public void setWeights(double[] weights)
Set all new weights.

Parameters:
weights - new weights to set

setWeight

public void setWeight(int i,
                      double weight)
Sets weight at given position.

Parameters:
i - position
weight - new value for weight at position i

activationFunction

public abstract double activationFunction(double in)
Activation function. Implement it to create the desired behaviour for the perceptron.

Parameters:
in - input value
Returns:
output value for activation

evaluate

public double evaluate(double[] in)
Evaluates a given input for the perceptron.

Parameters:
in - input to evaluate
Returns:
activation function applied to the weighted sum of the inputs

output

public abstract double output()
Used to get the output from all input neurons.

Returns:
activation function applied to the weighted sum of all inputs, which are taken from the input neurons

getThreshold

public double getThreshold()
Returns the threshold.

Returns:
threshold of the neutron

setThreshold

public void setThreshold(double threshold)
Sets the threshold.

Parameters:
threshold - The threshold to set

setClassValue

public void setClassValue(String classval)
Allows to set a class value for a perceptron (optional).

Parameters:
classval - the class value to set.

getClassValue

public String getClassValue()
Returns:
class value of the perceptron if it exists.

random

public static double random()
Returns a randomly chosen double between -1 and 1.

Returns:
random double number between -1 and 1

scalarProduct

public static double scalarProduct(double[] x,
                                   double[] y)
Computes the scalar Product of two vectors, represented as double arrays.

Parameters:
x - first array
y - second array
Returns:
scalar product of x and y


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.