/*
This is a proprietary part of DataMelt package.
License: the Creative Commons Attribution-Share Alike License; either version 3.0 of the License,
or any later version.
http://creativecommons.org/licenses/by-sa/3.0/
Redistributions of the source code, or parts of the source codes,
must retain the copyright notice, this list of conditions and the following disclaimer
(all at the top of each source code) and requires the written permission from DataMelt.
Redistribution in binary form of all or parts of a class must reproduce the
copyright notice, this list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution and requires the written permission of ScaVis
Details about license agreement or commercial use are: http://jwork.org/scavis/
*/
package jhpro.nnet;
/**
* This class builds a single neuron.
**/
public class Neuron implements java.io.Serializable
{
public Neuron()
{
init(0.0F);
}
public void init(float f)
{
input = f;
output = f;
outputError = 0.0F;
}
public void computeInput(float af[], float af1[])
{
input = 0.0F;
for(int i = 0; i < af.length; i++)
if(af[i] != 0.0F && af1[i] != 0.0F)
input += af[i] * af1[i];
input += af1[af1.length - 1];
}
/**
* Activation function is 1.0F / (1.0F + (float)Math.exp(-input))
**/
public void activateSigmoid()
{
output = 1.0F / (1.0F + (float)Math.exp(-input));
}
public void computeOutputError(float f)
{
if(output != 0.0F && output != 1.0F)
outputError = (f - output) * output * (1.0F - output);
}
public void computeOutputError(float af[], float af1[])
{
outputError = 0.0F;
for(int i = 0; i < af.length; i++)
if(af[i] != 0.0F && output != 0.0F && output != 1.0F)
outputError += af[i] * af1[i] * output * (1.0F - output);
}
public float getInput()
{
return input;
}
public float getOutput()
{
return output;
}
public float getOutputError()
{
return outputError;
}
float input;
float output;
float outputError;
}
Ads help maintain this website.