- java.lang.Object
-
- org.ojalgo.ann.ArtificialNeuralNetwork
-
public final class ArtificialNeuralNetwork extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classArtificialNeuralNetwork.Activatorhttps://en.wikipedia.org/wiki/Activation_functionstatic classArtificialNeuralNetwork.Error
-
Field Summary
Fields Modifier and Type Field Description private TrainingConfigurationmyConfigurationprivate PhysicalStore.Factory<java.lang.Double,?>myFactoryprivate CalculationLayer[]myLayers
-
Constructor Summary
Constructors Constructor Description ArtificialNeuralNetwork(NetworkBuilder builder)ArtificialNeuralNetwork(PhysicalStore.Factory<java.lang.Double,?> factory, int inputs, int[] layers)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description (package private) voidadjust(int layer, PhysicalStore<java.lang.Double> input, PhysicalStore<java.lang.Double> output, PhysicalStore<java.lang.Double> upstreamGradient, PhysicalStore<java.lang.Double> downstreamGradient)static NetworkBuilderbuilder(int numberOfNetworkInputNodes)static NetworkTrainerbuilder(int numberOfInputNodes, int... nodesPerCalculationLayer)Deprecated.Usebuilder(int)insteadstatic NetworkBuilderbuilder(PhysicalStore.Factory<java.lang.Double,?> factory, int numberOfNetworkInputNodes)static NetworkTrainerbuilder(PhysicalStore.Factory<java.lang.Double,?> factory, int numberOfInputNodes, int... nodesPerCalculationLayer)Deprecated.(package private) intcountInputNodes()(package private) intcountInputNodes(int layer)(package private) intcountOutputNodes()(package private) intcountOutputNodes(int layer)intdepth()(package private) static voiddoIdentity(PhysicalStore<java.lang.Double> output)(package private) static voiddoReLU(PhysicalStore<java.lang.Double> output)(package private) static voiddoSigmoid(PhysicalStore<java.lang.Double> output)(package private) static voiddoSoftMax(PhysicalStore<java.lang.Double> output)(package private) static voiddoTanh(PhysicalStore<java.lang.Double> output)booleanequals(java.lang.Object obj)static ArtificialNeuralNetworkfrom(java.io.DataInput input)Read (reconstruct) an ANN from the specified input previously written bywriteTo(DataOutput).static ArtificialNeuralNetworkfrom(java.io.File file)static ArtificialNeuralNetworkfrom(java.nio.file.Path path, java.nio.file.OpenOption... options)static ArtificialNeuralNetworkfrom(PhysicalStore.Factory<java.lang.Double,?> factory, java.io.DataInput input)Read (reconstruct) an ANN from the specified input previously written bywriteTo(DataOutput).static ArtificialNeuralNetworkfrom(PhysicalStore.Factory<java.lang.Double,?> factory, java.io.File file)static ArtificialNeuralNetworkfrom(PhysicalStore.Factory<java.lang.Double,?> factory, java.nio.file.Path path, java.nio.file.OpenOption... options)ArtificialNeuralNetwork.ActivatorgetActivator(int layer)doublegetBias(int layer, int output)(package private) ArtificialNeuralNetwork.ActivatorgetOutputActivator()doublegetWeight(int layer, int input, int output)(package private) java.util.List<MatrixStore<java.lang.Double>>getWeights()inthashCode()(package private) PhysicalStore<java.lang.Double>invoke(int layer, PhysicalStore<java.lang.Double> input, PhysicalStore<java.lang.Double> output)(package private) DataBatchnewBatch(int rows, int columns)NetworkInvokernewInvoker()With batch size 1NetworkInvokernewInvoker(int batchSize)If you create multiple invokers you can use them in different threads simutaneously - the invoker contains any/all invocation specific state.(package private) PhysicalStore<java.lang.Double>newStore(int rows, int columns)NetworkTrainernewTrainer()With batch size 1NetworkTrainernewTrainer(int batchSize)Only 1 trainer at the time.(package private) voidrandomise()(package private) voidscale(int layer, double factor)(package private) voidsetActivator(int layer, ArtificialNeuralNetwork.Activator activator)(package private) voidsetBias(int layer, int output, double bias)(package private) voidsetConfiguration(TrainingConfiguration configuration)(package private) voidsetWeight(int layer, int input, int output, double weight)Structure2D[]structure()java.lang.StringtoString()intwidth()voidwriteTo(java.io.DataOutput output)Will write (save) the ANN to the specified output.voidwriteTo(java.io.File file)voidwriteTo(java.nio.file.Path path, java.nio.file.OpenOption... options)
-
-
-
Field Detail
-
myConfiguration
private transient TrainingConfiguration myConfiguration
-
myFactory
private final PhysicalStore.Factory<java.lang.Double,?> myFactory
-
myLayers
private final CalculationLayer[] myLayers
-
-
Constructor Detail
-
ArtificialNeuralNetwork
ArtificialNeuralNetwork(NetworkBuilder builder)
-
ArtificialNeuralNetwork
ArtificialNeuralNetwork(PhysicalStore.Factory<java.lang.Double,?> factory, int inputs, int[] layers)
-
-
Method Detail
-
builder
public static NetworkBuilder builder(int numberOfNetworkInputNodes)
-
builder
@Deprecated public static NetworkTrainer builder(int numberOfInputNodes, int... nodesPerCalculationLayer)
Deprecated.Usebuilder(int)instead
-
builder
public static NetworkBuilder builder(PhysicalStore.Factory<java.lang.Double,?> factory, int numberOfNetworkInputNodes)
-
builder
@Deprecated public static NetworkTrainer builder(PhysicalStore.Factory<java.lang.Double,?> factory, int numberOfInputNodes, int... nodesPerCalculationLayer)
Deprecated.
-
from
public static ArtificialNeuralNetwork from(java.io.DataInput input) throws java.io.IOException
Read (reconstruct) an ANN from the specified input previously written bywriteTo(DataOutput).- Throws:
java.io.IOException
-
from
public static ArtificialNeuralNetwork from(java.io.File file)
- See Also:
from(DataInput)
-
from
public static ArtificialNeuralNetwork from(java.nio.file.Path path, java.nio.file.OpenOption... options)
- See Also:
from(DataInput)
-
from
public static ArtificialNeuralNetwork from(PhysicalStore.Factory<java.lang.Double,?> factory, java.io.DataInput input) throws java.io.IOException
Read (reconstruct) an ANN from the specified input previously written bywriteTo(DataOutput).- Throws:
java.io.IOException
-
from
public static ArtificialNeuralNetwork from(PhysicalStore.Factory<java.lang.Double,?> factory, java.io.File file)
- See Also:
from(DataInput)
-
from
public static ArtificialNeuralNetwork from(PhysicalStore.Factory<java.lang.Double,?> factory, java.nio.file.Path path, java.nio.file.OpenOption... options)
- See Also:
from(DataInput)
-
doIdentity
static void doIdentity(PhysicalStore<java.lang.Double> output)
-
doReLU
static void doReLU(PhysicalStore<java.lang.Double> output)
-
doSigmoid
static void doSigmoid(PhysicalStore<java.lang.Double> output)
-
doSoftMax
static void doSoftMax(PhysicalStore<java.lang.Double> output)
-
doTanh
static void doTanh(PhysicalStore<java.lang.Double> output)
-
depth
public int depth()
- Returns:
- The number of calculation layers
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
getActivator
public ArtificialNeuralNetwork.Activator getActivator(int layer)
-
getBias
public double getBias(int layer, int output)
-
getWeight
public double getWeight(int layer, int input, int output)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
newInvoker
public NetworkInvoker newInvoker()
With batch size 1- See Also:
newInvoker(int)
-
newInvoker
public NetworkInvoker newInvoker(int batchSize)
If you create multiple invokers you can use them in different threads simutaneously - the invoker contains any/all invocation specific state.- Parameters:
batchSize- The batch size - the number of batched invocations- Returns:
- The invoker
-
newTrainer
public NetworkTrainer newTrainer()
With batch size 1- See Also:
newTrainer(int)
-
newTrainer
public NetworkTrainer newTrainer(int batchSize)
Only 1 trainer at the time.- Parameters:
batchSize- The batch size - the number of batched training examples- Returns:
- The trainer
-
structure
public Structure2D[] structure()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
width
public int width()
- Returns:
- The max number of nodes in any layer
-
writeTo
public void writeTo(java.io.DataOutput output) throws java.io.IOExceptionWill write (save) the ANN to the specified output. Can then later be read back by usingfrom(DataInput).- Throws:
java.io.IOException
-
writeTo
public void writeTo(java.io.File file)
- See Also:
writeTo(DataOutput)
-
writeTo
public void writeTo(java.nio.file.Path path, java.nio.file.OpenOption... options)- See Also:
writeTo(DataOutput)
-
adjust
void adjust(int layer, PhysicalStore<java.lang.Double> input, PhysicalStore<java.lang.Double> output, PhysicalStore<java.lang.Double> upstreamGradient, PhysicalStore<java.lang.Double> downstreamGradient)
-
countInputNodes
int countInputNodes()
-
countInputNodes
int countInputNodes(int layer)
-
countOutputNodes
int countOutputNodes()
-
countOutputNodes
int countOutputNodes(int layer)
-
getOutputActivator
ArtificialNeuralNetwork.Activator getOutputActivator()
-
getWeights
java.util.List<MatrixStore<java.lang.Double>> getWeights()
-
invoke
PhysicalStore<java.lang.Double> invoke(int layer, PhysicalStore<java.lang.Double> input, PhysicalStore<java.lang.Double> output)
-
newBatch
DataBatch newBatch(int rows, int columns)
-
newStore
PhysicalStore<java.lang.Double> newStore(int rows, int columns)
-
randomise
void randomise()
-
scale
void scale(int layer, double factor)
-
setActivator
void setActivator(int layer, ArtificialNeuralNetwork.Activator activator)
-
setBias
void setBias(int layer, int output, double bias)
-
setConfiguration
void setConfiguration(TrainingConfiguration configuration)
-
setWeight
void setWeight(int layer, int input, int output, double weight)
-
-