diff --git a/scripts/keywordSpotting.dml b/scripts/keywordSpotting.dml index 6c46f804586..1f4bff40792 100644 --- a/scripts/keywordSpotting.dml +++ b/scripts/keywordSpotting.dml @@ -15,8 +15,8 @@ y_shuffled = Xy_shuffled[,num_col] # Labels, the last column [X_train, X_test, y_train, y_test] = split(X=X_shuffled, Y=y_shuffled, seed= 13) # Preprocess with fft Optionally move before split. -[X_train_re, X_train_im] = stft(X_train, 256, 128) -[X_test_re, X_test_im] = stft(X_test, 256, 128) +[X_train_re, X_train_im] = stft(X_train, 4, 2) +[X_test_re, X_test_im] = stft(X_test, 4, 2) X_train_re_sq = X_train_re^2 @@ -38,15 +38,15 @@ magnitudes_test = sqrt(sum_X_test_sq) bias = lm(X=magnitudes_train, y=y_train, reg=1e-1, maxi=10, verbose=TRUE) predictions = lmPredict(X=magnitudes_test, B=bias, verbose=FALSE) -sign_predictions = sign(predictions) -sign_Y = sign(y_test) +#sign_predictions = sign(predictions) +#sign_Y = sign(y_test) -correct = sum(sign_predictions == sign_Y) -total = nrow(y_test) -accuracy = correct / total +#correct = sum(sign_predictions == sign_Y) +#total = nrow(y_test) +#accuracy = correct / total #print(toString(predictions)) -print(toString(accuracy)) +#print(toString(accuracy)) R = lmPredictStats(yhat=predictions, ytest=y_test, lm=TRUE) print(toString(R)) diff --git a/src/main/java/org/apache/sysds/runtime/matrix/data/LibMatrixSTFT.java b/src/main/java/org/apache/sysds/runtime/matrix/data/LibMatrixSTFT.java index 0f8ae305a7e..98597f9cd2c 100644 --- a/src/main/java/org/apache/sysds/runtime/matrix/data/LibMatrixSTFT.java +++ b/src/main/java/org/apache/sysds/runtime/matrix/data/LibMatrixSTFT.java @@ -65,7 +65,7 @@ public static MatrixBlock[] stft(MatrixBlock re, MatrixBlock im, int windowSize, double[] re_inter = new double[out_len]; double[] im_inter = new double[out_len]; - ExecutorService pool = CommonThreadPool.get(1); + //ExecutorService pool = CommonThreadPool.get(1); for (int h = 0; h < rows; h++){ for (int i = 0; i < numberOfFramesPerRow; i++) { @@ -75,35 +75,14 @@ public static MatrixBlock[] stft(MatrixBlock re, MatrixBlock im, int windowSize, stftOutput_im[h * rowLength + i * windowSize + j] = im.getDenseBlockValues()[h * cols + i * stepSize + j]; } } - final int finalH = h; - final int finalI = i; - pool.submit(() -> fft_one_dim(stftOutput_re, stftOutput_im, re_inter, im_inter, finalH * rowLength + finalI * windowSize, finalH * rowLength + (finalI+1) * windowSize, windowSize, 1)); - awaitParallelExecution(pool); + //final int finalH = h; + //final int finalI = i; + fft_one_dim(stftOutput_re, stftOutput_im, re_inter, im_inter, h * rowLength + i * windowSize, h * rowLength + (i+1) * windowSize, windowSize, 1); + //pool.submit(() -> fft_one_dim(stftOutput_re, stftOutput_im, re_inter, im_inter, finalH * rowLength + finalI * windowSize, finalH * rowLength + (finalI+1) * windowSize, windowSize, 1)); + //awaitParallelExecution(pool); } } - - /* - for (int i = 0; i < stftOutput_re.length; i++) { - System.out.println(stftOutput_re[i] + stftOutput_im[i]); - } - - */ - int i = 0; - while (i < 1000000000) { - i = i + 1; - } - i = 0; - while (i < 1000000000) { - i = i + 1; - } - i = 0; - while (i < 1000000000) { - i = i + 1; - } - - - return new MatrixBlock[]{new MatrixBlock(rows, rowLength, stftOutput_re), new MatrixBlock(rows, rowLength, stftOutput_im)}; }