Skip to content

Commit

Permalink
Now SOM grows in cells with max mapped units, instead of max QE. Great
Browse files Browse the repository at this point in the history
advance in visualization!!!!
  • Loading branch information
vicente committed Feb 28, 2016
1 parent c2f85db commit 1278812
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
1 change: 1 addition & 0 deletions lfsom/src/lfsom/data/LFSData.java
Expand Up @@ -162,6 +162,7 @@ public LFSData(String fileName) {
boolean cambio_col = false;

cargador.setSource(new File(fileName));

Instances data1 = cargador.getDataSet();

double[][] matrix2 = new double[data1.size()][data1.numAttributes()];
Expand Down
34 changes: 22 additions & 12 deletions lfsom/src/lfsom/layers/LFSGrowingLayer.java
Expand Up @@ -101,8 +101,9 @@ public class LFSGrowingLayer {
// The "worst" error
private double maxQe = 0;

// The unif having maxQe
// The unit having maxQe
private LFSUnit unitmaxQe;
private LFSUnit unitmaxVec;

// Neighbour function to apply training
private int neighbourFunc = NEIGH_GAUSS;
Expand Down Expand Up @@ -1040,23 +1041,23 @@ private boolean controlTamanyo(LFSSOMProperties props, LFSData datos1,

LFSUnit d = null;
if (hazCol) {
if (this.unitmaxQe.getXPos() > 0) {
d = this.getUnit(this.unitmaxQe.getXPos() - 1,
this.unitmaxQe.getYPos());
if (this.unitmaxVec.getXPos() > 0) {
d = this.getUnit(this.unitmaxVec.getXPos() - 1,
this.unitmaxVec.getYPos());
} else {
d = this.getUnit(1, this.unitmaxQe.getYPos());
d = this.getUnit(1, this.unitmaxVec.getYPos());
}
} else if (hazFil) {
if (this.unitmaxQe.getYPos() > 0) {
d = this.getUnit(this.unitmaxQe.getXPos(),
this.unitmaxQe.getYPos() - 1);
if (this.unitmaxVec.getYPos() > 0) {
d = this.getUnit(this.unitmaxVec.getXPos(),
this.unitmaxVec.getYPos() - 1);
} else {
d = this.getUnit(this.unitmaxQe.getXPos(), 1);
d = this.getUnit(this.unitmaxVec.getXPos(), 1);
}
} else {
d = this.getMostDissimilarNeighbor(this.unitmaxQe);
d = this.getMostDissimilarNeighbor(this.unitmaxVec);
}
this.insertRowColumn(this.unitmaxQe, d, props.learnrate(),
this.insertRowColumn(this.unitmaxVec, d, props.learnrate(),
props.sigma());
okCalc = true;
props.setXYSize(this.xSize, this.ySize);
Expand Down Expand Up @@ -1262,6 +1263,7 @@ private void trainFinalOnline(int i, int numIterations,
private void compruebaErrUnits() {
this.maxQe = 0;
this.unitmaxQe = units[0][0];
this.unitmaxVec = units[0][0];
for (int j = 0; j < ySize; j++) {
for (int l = 0; l < xSize; l++) {
double err = units[l][j].getQError();
Expand All @@ -1270,6 +1272,11 @@ private void compruebaErrUnits() {
this.maxQe = err;
this.unitmaxQe = units[l][j];
}

double numVec = units[l][j].getNumberOfMappedInputs();
if (numVec > this.unitmaxVec.getNumberOfMappedInputs()) {
this.unitmaxVec = units[l][j];
}
}
}
}
Expand All @@ -1278,7 +1285,10 @@ private void compruebaErrUnits() {
private void growAndHier(int i, int numIterations,
LFSSOMProperties trainingProps) {

// mapSomeDataAfterTraining(data, data.numVectors() / 20);
// if (data.numVectors() > 5000) {
// int numMap = 5000;
// mapSomeDataAfterTraining(data, numMap);
// } else
mapCompleteDataAfterTraining(data);
this.calcQualityQError(data);
QError = this.getQError();// ualityMeasure("QError");
Expand Down

0 comments on commit 1278812

Please sign in to comment.