Skip to content
Snippets Groups Projects
Commit 16eddea3 authored by Walt Mankowski's avatar Walt Mankowski
Browse files

more debugging of broken thread code

parent 228b55bc
Branches gmm-thread
No related tags found
No related merge requests found
Pipeline #
...@@ -9,6 +9,7 @@ import java.nio.FloatBuffer; ...@@ -9,6 +9,7 @@ import java.nio.FloatBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Random; import java.util.Random;
import java.time.LocalTime;
import static org.bytedeco.javacpp.opencv_core.*; import static org.bytedeco.javacpp.opencv_core.*;
import static org.bytedeco.javacpp.opencv_imgproc.*; import static org.bytedeco.javacpp.opencv_imgproc.*;
...@@ -65,16 +66,17 @@ public class Demo_Pixel_Replication_Threads implements PlugInFilter { ...@@ -65,16 +66,17 @@ public class Demo_Pixel_Replication_Threads implements PlugInFilter {
Mat initMeans = randomInitMeans(k); Mat initMeans = randomInitMeans(k);
IJ.log(String.format("thread %d em randomInitMeans();", idx)); IJ.log(String.format("thread %d em randomInitMeans();", idx));
synchronized(lock1) { // synchronized(lock1) {
// try { // try {
IJ.log(String.format("before, thread %d, trained ", idx) + em.isTrained()); // IJ.log(String.format("before, thread %d, trained ", idx) + em.isTrained());
em.trainE(emMat, initMeans, new Mat(), new Mat(), logLikelihoods, labels, new Mat()); // em.trainE(emMat, initMeans, new Mat(), new Mat(), logLikelihoods, labels, new Mat());
IJ.log(String.format("after, thread %d, trained ", idx) + em.isTrained()); train(em, emMat, initMeans, new Mat(), new Mat(), logLikelihoods, labels, new Mat());
// IJ.log(String.format("after, thread %d, trained ", idx) + em.isTrained());
// } catch (Exception e) { // } catch (Exception e) {
// IJ.log("Caught exception in em.trainE: " + e.getMessage()); // IJ.log("Caught exception in em.trainE: " + e.getMessage());
// } // }
} // }
IJ.log(String.format("thread %d em em.trainE();", idx)); // IJ.log(String.format("thread %d em em.trainE();", idx));
synchronized(lock2) { synchronized(lock2) {
ems[idx] = em; ems[idx] = em;
...@@ -82,6 +84,14 @@ public class Demo_Pixel_Replication_Threads implements PlugInFilter { ...@@ -82,6 +84,14 @@ public class Demo_Pixel_Replication_Threads implements PlugInFilter {
} }
IJ.log(String.format("replicate %d score = %f", idx, em_scores[idx])); IJ.log(String.format("replicate %d score = %f", idx, em_scores[idx]));
} }
public synchronized void train(EM em, Mat emMat, Mat initMeans, Mat tmp1, Mat tmp2, Mat logLikelihoods, Mat labels, Mat tmp3) {
IJ.log(String.format("%s before, thread %d, trained ", LocalTime.now(), idx) + em.isTrained());
em.trainE(emMat, initMeans, new Mat(), new Mat(), logLikelihoods, labels, new Mat());
IJ.log(String.format("%s after, thread %d, trained ", LocalTime.now(), idx) + em.isTrained());
IJ.log(String.format("%s thread %d em em.trainE();", LocalTime.now(), idx));
}
} }
public Demo_Pixel_Replication_Threads() { public Demo_Pixel_Replication_Threads() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment