public abstract class LinkedNeuron extends java.lang.Object implements INeuron
Base implementation of a neuron of a hidden or output layer
Modifier and Type | Field and Description |
---|---|
protected boolean |
biased
Is biased?
|
protected Link[] |
links
Link array
|
protected Interval |
weightRange
Weight range
|
protected static <any> |
XML
Marshal/Unmarshal links and and a boolean indicating if the
neuron is input-biased
|
Constructor and Description |
---|
LinkedNeuron()
Empty constructor
|
Modifier and Type | Method and Description |
---|---|
LinkedNeuron |
copy(ILayer<? extends INeuron> previousLayer)
Returns a copy of this linked neuron
|
boolean |
equals(INeuron other)
Checks if this neuron is equal to another
|
Link |
getLink(int neuron)
Returns the link with the neuron specified (0 is bias neuron)
|
Link[] |
getLinks()
Returns the links array
|
int |
getNoflinks()
Returns the number of effective links of the neuron
|
Interval |
getWeightRange()
Returns the weight range associated to the links
|
int |
hashCode()
Returns an integer number that identifies the neuron
|
protected abstract double |
initInput()
Init the input of the neuron (0 or 1 depending on the kind of neuron)
|
protected abstract double |
inputFunction(double input,
double in,
double weight)
Input function of the neuron.
|
boolean |
isBiased()
Returns a boolean indicating if the layer has a bias neuron
|
void |
keepRelevantLinks(double significativeWeight)
Keep relevant links, that is, those links whose weight is higher
than certain number
|
double |
operate(double[] inputs)
Operates this neuron, using an input array.
|
double[] |
operate(double[][] inputs)
Operates this neuron using an input matrix as argument
|
protected abstract double |
outputFunction(double input)
Output function of the neuron
|
double |
randomWeight(IRandGen randGen,
double significativeWeight)
Returns a random weight for a link
|
void |
setBiased(boolean biased)
Sets a boolean indicating if the layer has a bias neuron
|
void |
setLink(int neuron,
Link link)
Sets the link with the neuron specified (0 is bias neuron)
|
void |
setLinks(Link[] links)
Sets the links of the neuron
|
void |
setWeightRange(Interval weightRange)
Sets the weight range associated to the links
|
protected static final <any> XML
Marshal/Unmarshal links and and a boolean indicating if the neuron is input-biased
protected Link[] links
protected boolean biased
protected Interval weightRange
public Link[] getLinks()
Returns the links array
public void setLinks(Link[] links)
Sets the links of the neuron
links
- [] New links arraypublic Link getLink(int neuron)
Returns the link with the neuron specified (0 is bias neuron)
neuron
- neuron's indexpublic void setLink(int neuron, Link link)
Sets the link with the neuron specified (0 is bias neuron)
neuron
- Neuron to set the linklink
- New link of the neuron specifiedpublic boolean isBiased()
Returns a boolean indicating if the layer has a bias neuron
public void setBiased(boolean biased)
Sets a boolean indicating if the layer has a bias neuron
biased
- Boolean has bias neuronpublic Interval getWeightRange()
Returns the weight range associated to the links
public void setWeightRange(Interval weightRange)
Sets the weight range associated to the links
weightRange
- New weight rangepublic boolean equals(INeuron other)
Checks if this neuron is equal to another
public int hashCode()
Returns an integer number that identifies the neuron
public double operate(double[] inputs)
Operates this neuron, using an input array. This means:
1) apply the input function to all the inputs neuron and sum the result
2) apply the output function to the result
public double[] operate(double[][] inputs)
Operates this neuron using an input matrix as argument
public int getNoflinks()
Returns the number of effective links of the neuron
public double randomWeight(IRandGen randGen, double significativeWeight)
Returns a random weight for a link
randGen
- Random number generatorsignificativeWeight
- Minimum absolute value of the new weightpublic void keepRelevantLinks(double significativeWeight)
Keep relevant links, that is, those links whose weight is higher than certain number
significativeWeight
- Significative weightpublic LinkedNeuron copy(ILayer<? extends INeuron> previousLayer)
Returns a copy of this linked neuron
previousLayer
- Previous layer to which copied neuron
is going to be linkedprotected abstract double initInput()
Init the input of the neuron (0 or 1 depending on the kind of neuron)
protected abstract double inputFunction(double input, double in, double weight)
Input function of the neuron. Update input for each input neuron
input
- Old inputin
- Output of the input neuronweight
- Weight of the link to the input neuronprotected abstract double outputFunction(double input)
Output function of the neuron
input
- Input of the neuron