Skip to content

micartey/NeuralNetwork

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NeuralNetwork


IntroductionGetting startedTroubleshooting

📚 Introduction

This is a object oriented neural network where each Layer has a n-amount of Neurons and each Neuron is capable of having it's own activation function. The structure of the Neurons and their connections to other Layers doesn't sepperate itself from other neural networks where each Neuron is connected to each Neuron in the next Layer

🧱 Create a neural network

You can create a neural network with a single activation function for each Neuron which also indexes the Neurons automatically

    NeuralNetwork network = new NeuralNetwork(FunctionType.SIGMOID, 2, 3, 1);

Alternatively, you can create each Layer individually which also requires each Neuron to be created individually with its own activation function

    NeuralNetwork network = new NeuralNetwork(
        new Layer(
            new Neuron(FunctionType.SIGMOID),
            new Neuron(FunctionType.SIGMOID)
        ), new Layer(
            new Neuron(FunctionType.SIGMOID),
            new Neuron(FunctionType.SIGMOID),
            new Neuron(FunctionType.SIGMOID)
        ), new Layer(
            new Neuron(FunctionType.SIGMOID)
        )
    );

🏋🏽‍♂️ Training a neural network

To train your neural network you can use either DataSets or normal double arrays. The following example trains the OR-Gate to a neural network.

    NeuralNetwork network = new NeuralNetwork(FunctionType.SIGMOID, 2, 3, 1);

    DataSet dataSet = new DataSet(
            new DataRow(new double[]{1, 0}, new double[]{1}),
            new DataRow(new double[]{1, 1}, new double[]{1}),
            new DataRow(new double[]{0, 1}, new double[]{1}),
            new DataRow(new double[]{0, 0}, new double[]{0})
    );

    /* TRAIN ON THE DATASET FOR 1000 CICLES */
    network.train(dataSet, 1000, .03);