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

Merge branch 'cli_app'

parents b8c0c186 5aca292f
Branches
No related tags found
No related merge requests found
......@@ -78,7 +78,11 @@ public class QCMPFileHeader {
}
byte[] magicBuffer = new byte[QCMP_MAGIC_VALUE.length()];
assert (inputStream.readNBytes(magicBuffer, 0, QCMP_MAGIC_VALUE.length()) == QCMP_MAGIC_VALUE.length());
final int readFromMagic = inputStream.readNBytes(magicBuffer, 0, QCMP_MAGIC_VALUE.length());
if (readFromMagic != QCMP_MAGIC_VALUE.length()) {
// Invalid magic value.
return false;
}
magicValue = new String(magicBuffer);
if (!magicValue.equals(QCMP_MAGIC_VALUE)) {
......
......@@ -205,7 +205,6 @@ public class LloydMaxU16ScalarQuantization {
ArrayList<QTrainIteration> solutionHistory = new ArrayList<>();
recalculateBoundaryPoints();
// recalculateCentroids();
initializeCentroids();
currentMse = getCurrentMse();
......@@ -225,9 +224,6 @@ public class LloydMaxU16ScalarQuantization {
recalculateCentroids();
}
// TODO(Moravec): Check if we are improving MSE.
// Save the best centroids, the lowest MSE.
currMAE = calculateMAE();
prevMse = currentMse;
......@@ -236,12 +232,6 @@ public class LloydMaxU16ScalarQuantization {
// 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);
solutionHistory.add(new QTrainIteration(++iteration, currentMse, currentMse, psnr, psnr));
// dist = (prevMse - currentMse) / currentMse;
......@@ -253,23 +243,17 @@ public class LloydMaxU16ScalarQuantization {
psnr));
}
// if (mseImprovement < 1.0 && mseImprovement > 0.0005) {
// System.out.println("----- low improvement " + mseImprovement);
// }
if (mseImprovement < 1.0) {
if ((++noImprovementCounter) >= PATIENCE) {
break;
}
}
} while (true); //0.001 //0.0005// || currMAE > 1500//mseImprovement > 0.0005
} while (true);
if (verbose) {
System.out.println("\nFinished training.");
}
System.out.println(String.format("Final MAE: %.4f after %d iterations", currMAE, iteration));
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