-
Notifications
You must be signed in to change notification settings - Fork 0
Learning
Class for network learning is LNetwork.
First you need to create this object. There are three option:
-
Manually set up weights
-
Read previus network from disc
-
Use special constructor
-
I described in Symulation page The only change is using new LNetwork() constructor and next invocing setWeights(float[][][] weights) method. Remember to set up function with setFunction(Function function) method.
-
Also described in Symulation page but instead of FileS.readNetwork(String fileName) use FileL.readNetwork(String fileName)
-
There is constructor creating "blank"(with random weights) network with given layers size, input numer and function: public LNetwork(int inputsNumber,int[] layersSize, Function function)
I skiped class and method declaration lines
String fileName="yourNetwork"; LNetwork network=FileL.readNetwork(fileName); //Load your network from disc
int inputNumber=2; float[][][] weights=new float[1][2][2]; float[0][0][0]=1; float[0][0][1]=2; float[0][1][0]=3; float[0][1][1]=4;
Function fuction=new Linear(); LNetwork network=new LNetwork();
network.setWeights(weights); network.setFunction(function);
int inputNumber=2; int[] layersSize=new int[]{2}; Function function=new Linear(); LNetwork network=new LNetwork(inputNumber, layersSize, function);
To teach our LNetwork we need a teacher (Teacher class), and learning sequence(Array of LearningSequence object)
First we'll create teacher. We have Teacher(float N,float M,long cyclesNumber) constructor; N is param determining speed of learn, should be less then 1 M is momentum, should be less then 1 cyclesNumber is simply how much cycles numer teacher make
When we have teacher we must have data we want to teach our student-network. Data are storen in LearningSequence[] array. LearningSequece constains float[] input and float[] output. output constains the data we want have in output of network for specyfic input. we can use new LearningSequence(float[] input,float[] output); or ls.setInput(float[] input), ls.setOutput(float[] output);
We can also use FilesL.readLS(String fileName) to read full(not one LearningSequece object, but array of them) from disc
When we have our LearningSeqence array and teacher we call methods: network.setLS(LearningSequence ourLS); teacher.setNetwork(network);
after all we only need to invoke teach(); on our teacher and wait until it finished
If your resouls are NaN in network output decrease N and/or M.