/*
This is a proprietary part of DataMelt package.
License: the Creative Commons Attribution-Share Alike License; either version 3.0 of the License,
or any later version.
http://creativecommons.org/licenses/by-sa/3.0/
Redistributions of the source code, or parts of the source codes,
must retain the copyright notice, this list of conditions and the following disclaimer
(all at the top of each source code) and requires the written permission from DataMelt.
Redistribution in binary form of all or parts of a class must reproduce the
copyright notice, this list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution and requires the written permission of ScaVis
Details about license agreement or commercial use are: http://jwork.org/scavis/
*/
package jhpro.nnet;
public class NeuronMatrix {
public NeuronMatrix(int i) {
xSize = i;
ySize = 1;
mapNeuron = new MapNeuron[xSize * ySize];
for (int j = 0; j < i; j++)
mapNeuron[j] = new MapNeuron();
}
public NeuronMatrix(int i, int j) {
xSize = i;
ySize = j;
mapNeuron = new MapNeuron[i * j];
int k = 0;
for (int l = 0; l < i; l++) {
for (int i1 = 0; i1 < j; i1++)
mapNeuron[k++] = new MapNeuron();
}
}
public void init(InputValue ainputvalue[]) {
int i = 0;
for (int j = 0; j < xSize; j++) {
for (int k = 0; k < ySize; k++) {
mapNeuron[i].init(j, k);
i++;
}
}
}
public int size() {
return mapNeuron.length;
}
public int xSize() {
return xSize;
}
public int ySize() {
return ySize;
}
public MapNeuron[] getMapNeurons() {
return mapNeuron;
}
public MapNeuron computeActivationCenter(NeuronLayer neuronlayer,
WeightMatrix weightmatrix) {
float f = 1E+20F;
int i = 0;
float af[] = new float[weightmatrix.size()];
float af2[] = new float[neuronlayer.size()];
af2 = neuronlayer.getOutput();
for (int j = 0; j < mapNeuron.length; j++) {
float af1[] = weightmatrix.getInputWeights(j);
float f1 = 0.0F;
for (int k = 0; k < af2.length; k++)
if (af2[k] != af1[k])
f1 += (af2[k] - af1[k]) * (af2[k] - af1[k]);
if (f1 < f) {
f = f1;
i = j;
}
}
return mapNeuron[i];
}
public float[] getFeedback(MapNeuron mapneuron, double d) {
float af[] = new float[mapNeuron.length];
float f = (float) (2D * d * d);
for (int i = 0; i < mapNeuron.length; i++)
af[i] = mapNeuron[i].computeFeedback(mapneuron, f);
return af;
}
MapNeuron mapNeuron[];
int nr;
int xSize;
int ySize;
}
Ads help maintain this website.