edu.rice.comp440.net
Class HiddenUnit
java.lang.Object
|
+--edu.rice.comp440.net.HiddenUnit
- public class HiddenUnit
- extends java.lang.Object
- implements Unit
- See Also:
- Serialized Form
Constructor Summary |
protected |
HiddenUnit(Unit[] units,
double[] weights)
Builds a hidden unit taking the provided number of
inputs. |
protected |
HiddenUnit(Unit[] units,
java.util.Random random)
Builds a hidden unit taking the provided number of
inputs. |
Method Summary |
protected double |
getSum()
Returns the sum of all of the inputs and weights |
double |
getValue()
Returns the current value of this input |
void |
randomizeWeights(java.util.Random random)
Generates a new weight |
void |
recompute()
Recomputes the value of this hidden unit, querying it's
prior inputs. |
protected double |
sigmoid(double x)
Implements the sigmoid function to provide the non-linearity
to this function. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
MIN_INITIAL_WEIGHT
public static final int MIN_INITIAL_WEIGHT
MAX_INITIAL_WEIGHT
public static final int MAX_INITIAL_WEIGHT
weights
public double[] weights
units
protected Unit[] units
value
protected double value
HiddenUnit
protected HiddenUnit(Unit[] units,
java.util.Random random)
- Builds a hidden unit taking the provided number of
inputs. Sets the initial weights to be random
values to be 0.
- Parameters:
units
- The input units to this unitrandom
- The random number generator
HiddenUnit
protected HiddenUnit(Unit[] units,
double[] weights)
- Builds a hidden unit taking the provided number of
inputs. Sets the initial weights to be a copy of
the provided weights
- Parameters:
units
- The input units to this unitweights
- The weights to use
randomizeWeights
public void randomizeWeights(java.util.Random random)
- Generates a new weight
- Parameters:
random
- The rng- Returns:
- A new value
getSum
protected double getSum()
- Returns the sum of all of the inputs and weights
- Returns:
- the sum
recompute
public void recompute()
- Recomputes the value of this hidden unit, querying it's
prior inputs.
- Specified by:
- recompute in interface Unit
getValue
public double getValue()
- Returns the current value of this input
- Specified by:
- getValue in interface Unit
- Returns:
- The current value of this input
sigmoid
protected double sigmoid(double x)
- Implements the sigmoid function to provide the non-linearity
to this function. Simply returns
1 / (1 + e^-x)
- Parameters:
x
- The value to apply the function to- Returns:
- The result