Skip to content
Snippets Groups Projects
Commit 0e3bea74 authored by Vojtech Moravec's avatar Vojtech Moravec
Browse files

Clened the LloydMax class after the rewrite.

parent 9c7f6340
No related branches found
No related tags found
No related merge requests found
...@@ -205,7 +205,6 @@ public class LloydMaxU16ScalarQuantization { ...@@ -205,7 +205,6 @@ public class LloydMaxU16ScalarQuantization {
ArrayList<QTrainIteration> solutionHistory = new ArrayList<>(); ArrayList<QTrainIteration> solutionHistory = new ArrayList<>();
recalculateBoundaryPoints(); recalculateBoundaryPoints();
// recalculateCentroids();
initializeCentroids(); initializeCentroids();
currentMse = getCurrentMse(); currentMse = getCurrentMse();
...@@ -225,9 +224,6 @@ public class LloydMaxU16ScalarQuantization { ...@@ -225,9 +224,6 @@ public class LloydMaxU16ScalarQuantization {
recalculateCentroids(); recalculateCentroids();
} }
// TODO(Moravec): Check if we are improving MSE.
// Save the best centroids, the lowest MSE.
currMAE = calculateMAE(); currMAE = calculateMAE();
prevMse = currentMse; prevMse = currentMse;
...@@ -236,12 +232,6 @@ public class LloydMaxU16ScalarQuantization { ...@@ -236,12 +232,6 @@ public class LloydMaxU16ScalarQuantization {
// System.out.println(String.format("Improvement: %.4f", mseImprovement)); // System.out.println(String.format("Improvement: %.4f", mseImprovement));
// if ((prevMAE < currMAE) && (iteration != 0)) {
// System.err.println(String.format(
// "MAE = +%.5f",
// currMAE - prevMAE));
// }
psnr = Utils.calculatePsnr(currentMse, U16.Max); psnr = Utils.calculatePsnr(currentMse, U16.Max);
solutionHistory.add(new QTrainIteration(++iteration, currentMse, currentMse, psnr, psnr)); solutionHistory.add(new QTrainIteration(++iteration, currentMse, currentMse, psnr, psnr));
// dist = (prevMse - currentMse) / currentMse; // dist = (prevMse - currentMse) / currentMse;
...@@ -253,23 +243,17 @@ public class LloydMaxU16ScalarQuantization { ...@@ -253,23 +243,17 @@ public class LloydMaxU16ScalarQuantization {
psnr)); psnr));
} }
// if (mseImprovement < 1.0 && mseImprovement > 0.0005) {
// System.out.println("----- low improvement " + mseImprovement);
// }
if (mseImprovement < 1.0) { if (mseImprovement < 1.0) {
if ((++noImprovementCounter) >= PATIENCE) { if ((++noImprovementCounter) >= PATIENCE) {
break; break;
} }
} }
} while (true); //0.001 //0.0005// || currMAE > 1500//mseImprovement > 0.0005 } while (true);
if (verbose) { if (verbose) {
System.out.println("\nFinished training."); System.out.println("\nFinished training.");
} }
System.out.println(String.format("Final MAE: %.4f after %d iterations", currMAE, iteration));
return solutionHistory.toArray(new QTrainIteration[0]); return solutionHistory.toArray(new QTrainIteration[0]);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment