|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.vizzini.ai.neuralnetwork.AbstractNeuralNetwork
abstract class AbstractNeuralNetwork
Provides base functionality for neural networks.
The network consists of an input layer, zero or more hidden layers, and an output layer. Layers before the output layer may optionally contain a bias node.
Constructor Summary | |
---|---|
AbstractNeuralNetwork()
|
Method Summary | |
---|---|
void |
addConnector(IConnector connector)
Add the given connector. |
void |
addLayer(ILayer layer)
Add the given layer. |
void |
adjustWeights(int fromLayer,
int toLayer,
double[][] deltas)
Adjust the given layer's weights by adding the given deltas. |
Object |
clone()
Return a clone of this instance. |
void |
configure(Properties properties)
Configure this object using the given properties. |
Iterator |
connectorIterator(String toLayerName)
Return an iterator over the collection of connectors with the given to layer. |
boolean |
equals(Object object)
Return true if the given object is equal to this. |
double[] |
evaluate(double[] inputs)
Apply the given inputs and return the output of the neural network. |
void |
fillWeights(double value)
Assign the given value to all weights of the neural network. |
IActivationFunction |
getActivationFunction(int layerIndex)
Return the activation function. |
Properties |
getConfiguration()
Return the configuration of this network. |
IConnector |
getConnector(ILayer fromLayer,
ILayer toLayer)
Return the connector for the given parameters. |
IConnector |
getConnector(int fromLayerIndex,
int toLayerIndex)
Return the connector for the given parameters. |
IConnector |
getConnector(String fromLayerName,
String toLayerName)
Return the connector for the given parameters. |
int |
getConnectorCount()
Return the number of connectors. |
protected ConnectorCollection |
getConnectors()
|
IScaler |
getInputScaler()
Return the input scaler. |
ILayer |
getLayer(int index)
Return the layer at the given index. |
int |
getLayerCount()
Return the number of layers. |
protected List |
getLayers()
|
int |
getMaxOutputValueIndex()
Return the index of the output node with the maximum value. |
double |
getNodeInput(int layerIndex,
int i)
Return the node input value for the given parameters. |
double |
getNodeOutput(int layerIndex,
int i)
Return the node output value for the given parameters. |
ILayer |
getOutputLayer()
Return the output layer. |
int |
getOutputLayerIndex()
Return the output layer index. |
double[] |
getOutputs()
Return the output layer node values. |
IScaler |
getOutputScaler()
Return the output scaler. |
double |
getWeight(int fromLayer,
int i,
int toLayer,
int j)
Return the weight for the given parameters. |
double[] |
getWeights(int fromLayer,
int i,
int toLayer)
Return the weights for the given parameters. |
int |
hashCode()
Returns a hash code value for the object. |
int |
indexOf(ILayer layer)
Return the index of the given layer. |
boolean |
isConnected(ILayer fromLayer,
ILayer toLayer)
Return true if this network has a connector from the given layer to the given layer. |
boolean |
isConnected(int fromIndex,
int toIndex)
Return true if this network has a connector from the given layer to the given layer. |
void |
randomizeWeights()
Assign random weights to the neural network in [-0.1,0.1]. |
void |
randomizeWeights(double range)
Assign random weights to the neural network. |
void |
setActivationFunction(IActivationFunction function)
Set the activation function. |
void |
setActivationFunction(int layer,
IActivationFunction function)
Set the activation function for the given layer index. |
protected void |
setConnectors(ConnectorCollection connectors)
|
void |
setInputs(double[] inputs)
Set the values of the input nodes. |
void |
setInputScaler(IScaler scaler)
Set the input scaler. |
protected void |
setLayers(List layers)
|
void |
setNodeInput(int layerIndex,
int i,
double value)
Set the node input value for the given parameters. |
void |
setOutputScaler(IScaler scaler)
Set the output scaler. |
void |
setWeight(int fromLayer,
int i,
int toLayer,
int j,
double weight)
Set the weight for the given parameters. |
void |
store(OutputStream outputStream)
Store the neural network to the given output stream. |
String |
toString()
Return a string representation of this object. |
void |
zeroWeights()
Assign zero weights to the neural network. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
AbstractNeuralNetwork()
Method Detail |
---|
public void addConnector(IConnector connector)
addConnector
in interface INeuralNetwork
connector
- Connector.public void addLayer(ILayer layer)
addLayer
in interface INeuralNetwork
layer
- Layer.public void adjustWeights(int fromLayer, int toLayer, double[][] deltas)
adjustWeights
in interface INeuralNetwork
fromLayer
- From layer index, where 0=input layer, and
layerCount-1=output layer.toLayer
- To layer index, where 0=input layer, and
layerCount-1=output layer.deltas
- Weight deltas for the given layer.public Object clone()
clone
in interface INeuralNetwork
clone
in class Object
public void configure(Properties properties) throws InstantiationException, IllegalAccessException
configure
in interface INeuralNetwork
InstantiationException
IllegalAccessException
public Iterator connectorIterator(String toLayerName)
connectorIterator
in interface INeuralNetwork
toLayerName
- To layer name.public boolean equals(Object object)
equals
in class Object
object
- The object to compare.public double[] evaluate(double[] inputs)
evaluate
in interface INeuralNetwork
public void fillWeights(double value)
fillWeights
in interface INeuralNetwork
public IActivationFunction getActivationFunction(int layerIndex)
getActivationFunction
in interface INeuralNetwork
layerIndex
- Layer index, where 0=input layer, and
layerCount-1=output layer.public Properties getConfiguration()
getConfiguration
in interface INeuralNetwork
public IConnector getConnector(int fromLayerIndex, int toLayerIndex)
getConnector
in interface INeuralNetwork
fromLayerIndex
- From layer index.toLayerIndex
- To layer index.public IConnector getConnector(ILayer fromLayer, ILayer toLayer)
fromLayer
- From layer.toLayer
- To layer.public IConnector getConnector(String fromLayerName, String toLayerName)
fromLayerName
- From layer name.toLayerName
- To layer name.public int getConnectorCount()
getConnectorCount
in interface INeuralNetwork
public IScaler getInputScaler()
getInputScaler
in interface INeuralNetwork
public ILayer getLayer(int index)
getLayer
in interface INeuralNetwork
public int getLayerCount()
getLayerCount
in interface INeuralNetwork
public int getMaxOutputValueIndex()
getMaxOutputValueIndex
in interface INeuralNetwork
public double getNodeInput(int layerIndex, int i)
getNodeInput
in interface INeuralNetwork
layerIndex
- Layer index, where 0=input layer, and layerCount-1=output
layer.i
- Node index.public double getNodeOutput(int layerIndex, int i)
getNodeOutput
in interface INeuralNetwork
layerIndex
- Layer index, where 0=input layer, and layerCount-1=output
layer.i
- Node index.public ILayer getOutputLayer()
getOutputLayer
in interface INeuralNetwork
public int getOutputLayerIndex()
getOutputLayerIndex
in interface INeuralNetwork
public double[] getOutputs()
getOutputs
in interface INeuralNetwork
public IScaler getOutputScaler()
getOutputScaler
in interface INeuralNetwork
public double getWeight(int fromLayer, int i, int toLayer, int j)
getWeight
in interface INeuralNetwork
fromLayer
- From layer index, where 0=input layer, and
layerCount-1=output layer.i
- From layer node index.toLayer
- To layer index, where 0=input layer, and
layerCount-1=output layer.j
- To layer node index.public double[] getWeights(int fromLayer, int i, int toLayer)
getWeights
in interface INeuralNetwork
fromLayer
- From layer index, where 0=input layer, and
layerCount-1=output layer.i
- From layer node index.toLayer
- To layer index, where 0=input layer, and
layerCount-1=output layer.public int hashCode()
hashCode
in class Object
public int indexOf(ILayer layer)
indexOf
in interface INeuralNetwork
public boolean isConnected(int fromIndex, int toIndex)
isConnected
in interface INeuralNetwork
public boolean isConnected(ILayer fromLayer, ILayer toLayer)
isConnected
in interface INeuralNetwork
public void randomizeWeights()
randomizeWeights
in interface INeuralNetwork
public void randomizeWeights(double range)
randomizeWeights
in interface INeuralNetwork
range
- ±Range of random weights around zero.public void setActivationFunction(IActivationFunction function)
setActivationFunction
in interface INeuralNetwork
public void setActivationFunction(int layer, IActivationFunction function)
setActivationFunction
in interface INeuralNetwork
layer
- Layer index, where 0=input layer, and layerCount-1=output
layer.public void setInputs(double[] inputs)
setInputs
in interface INeuralNetwork
public void setInputScaler(IScaler scaler)
setInputScaler
in interface INeuralNetwork
public void setNodeInput(int layerIndex, int i, double value)
setNodeInput
in interface INeuralNetwork
layerIndex
- Layer index, where 0=input layer, and layerCount-1=output
layer.i
- Node index.public void setOutputScaler(IScaler scaler)
setOutputScaler
in interface INeuralNetwork
public void setWeight(int fromLayer, int i, int toLayer, int j, double weight)
setWeight
in interface INeuralNetwork
fromLayer
- From layer index, where 0=input layer, and
layerCount-1=output layer.i
- From layer node index.toLayer
- To layer index, where 0=input layer, and
layerCount-1=output layer.j
- To layer node index.weight
- New weight.public void store(OutputStream outputStream) throws IOException
store
in interface INeuralNetwork
IOException
public String toString()
toString
in interface INeuralNetwork
toString
in class Object
public void zeroWeights()
zeroWeights
in interface INeuralNetwork
protected ConnectorCollection getConnectors()
protected List getLayers()
protected void setConnectors(ConnectorCollection connectors)
connectors
- the connectors to setprotected void setLayers(List layers)
layers
- the layers to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2007 Vizzini.org. All Rights Reserved. | 2007.12.25.03.00.02 |