Conditional Digital Feedback; is it a good Idea? (Neural Networks)

AI Thread Summary
The discussion revolves around the implementation of an Expectation-Maximization (EM) algorithm in Java for a neural network, focusing on the correctness of the code and the implications of conditional digital feedback. The original E and M steps were questioned for their effectiveness, particularly regarding the relationship between the theta values. Adjustments were made to the MStep function to refine the calculations, with a focus on ensuring consistency between parameters. Concerns were raised about the feasibility of releasing the software for mobile devices, considering performance, battery consumption, and synchronization issues. The conversation highlights the complexities of developing efficient neural network algorithms while addressing practical deployment challenges.
ADDA
Messages
67
Reaction score
2
In this example:



The input multiplier to the artificial neural network, at the bottom of the screen, for each note is determined by an output of an Expectation Maxamazation sequence that converges after ten iterations with input of the artificial neural network's output above a threshhold.

First, does this code look correct?

Java:
package com.adda.test;

public class EM {
    public float[] theta;
    private float[][] ml;
    private boolean[][] input;
    private int n, nsets, ncount;
   
    public EM () {
        this.n = 2;
        this.ncount = CONSTANTS.NFRAMES_COUNT;
        this.nsets = CONSTANTS.NFRAMES_SETS;
   
        this.theta = new float[2];
        this.ml = new float[this.nsets][this.n];
        this.input = new boolean[this.nsets][this.ncount];
       
        this.theta[0] = 0.45f;
        this.theta[1] = 0.55f;
    }
   
    public void setInput(boolean[] notes) {
        int itr, aitr, bitr;
       
        bitr = 0;
        for (itr = 0; itr < this.nsets; itr += 1) {
            for (aitr = 0; aitr < this.ncount; aitr += 1) {
                this.input[itr][aitr] = notes[bitr];
               
                bitr += 1;
            }
        }
       
   
        return;
    }
   
    private void EStep() {
        int itr, c, aitr;
       
        for (aitr = 0; aitr < this.nsets; aitr += 1) {
            c = 0;
            for (itr = 0; itr < this.ncount; itr += 1) {
                if (this.input[aitr][itr]) c += 1;
            }
            this.ml[aitr][0] = this.theta[0] * ((float)(this.ncount - c) / (float)this.ncount);
            this.ml[aitr][1] = this.theta[1] * ((float)c / (float)this.ncount);
        }
    
        return;
    }

   
    private void MStep() {
        float[][] ntheta = new float[this.nsets][2];
        int itr, c, aitr;
   
        for (aitr = 0; aitr < this.nsets; aitr += 1) {
            c = 0;
            for (itr = 0; itr < this.ncount; itr += 1) {
                if (this.input[aitr][itr]) c += 1;
            }
           
            ntheta[aitr][0] = (float)(this.ncount - c) * this.ml[aitr][0] + 0.1f;
            ntheta[aitr][1] = (float)c * this.ml[aitr][1] + 0.1f;
           
        }
       
        this.theta[0] = ntheta[0][0] / (ntheta[0][0] + ntheta[0][1]);
       
        this.theta[1] = ntheta[1][1] / (ntheta[1][0] + ntheta[1][1]);
       
   
        return;
    }
   

    public void iterate() {
        int itr;
       
        for (itr = 0; itr < 10; itr += 1) {
            this.EStep();
            this.MStep();
        }
   
        return;
    }
   
    public boolean isOn() {
       
        boolean ret = (  (this.theta[1] > CONSTANTS.THRESH) );
//     if (ret)
        System.out.print("\t" + ret + " " + this.theta[0] + " " + this.theta[1] + " ");
   
        return ret;
    }
   
}

I've adopted this code from this article:

http://www.cmi.ac.in/~madhavan/courses/datamining12/reading/em-tutorial.pdf

I might be doing something wrong in the E Step. Every theta is a conjugate of the other. Is that a desired result?

Second, would conditional feedback be plausible to even release to the general public? Is it a good idea? I've seen somewhere that 1/5 less of the max is desired for a runtime loop. Does that mean 0.2x or (1.0 - 0.2)x ? Seriously.
 
Technology news on Phys.org
First, this function:

ADDA said:
private void MStep() {
float[][] ntheta = new float[this.nsets][2];
int itr, c, aitr;

for (aitr = 0; aitr < this.nsets; aitr += 1) {
c = 0;
for (itr = 0; itr < this.ncount; itr += 1) {
if (this.input[aitr][itr]) c += 1;
}

ntheta[aitr][0] = (float)(this.ncount - c) * this.ml[aitr][0] + 0.1f;
ntheta[aitr][1] = (float)c * this.ml[aitr][1] + 0.1f;

}

this.theta[0] = ntheta[0][0] / (ntheta[0][0] + ntheta[0][1]);

this.theta[1] = ntheta[1][1] / (ntheta[1][0] + ntheta[1][1]);


return;
}

I changed to this function:

Java:
private void MStep() {
        float[][] ntheta = new float[this.nsets][2];
        int itr, c, aitr;
   
        for (aitr = 0; aitr < this.nsets; aitr += 1) {
            c = 0;
            for (itr = 0; itr < this.ncount; itr += 1) {
                if (this.input[aitr][itr]) c += 1;
            }
           
            ntheta[aitr][0] = (float)(this.ncount - c) * this.ml[aitr][0] + 0.01f;
            ntheta[aitr][1] = (float)c * this.ml[aitr][1] + 0.01f;
           
        }
       
        this.theta[0] = ntheta[0][0] / (ntheta[0][0] + ntheta[0][1]);
       
        this.theta[1] = ntheta[0][1] / (ntheta[0][0] + ntheta[0][1]);
       
        this.theta[0] *= ntheta[1][0] / (ntheta[1][0] + ntheta[1][1]);
       
        this.theta[1] *= ntheta[1][1] / (ntheta[1][0] + ntheta[1][1]);
   
        return;
    }

It made more sense to make the off parameter, 0 indexed theta, the same for frame one and two, and the on parameter. Is this correct?

As far as digital feedback goes, I turned it off. Basically the idea was for event detection. When a note is true or on, I wanted to turn it off, which is useful for detecting the next note and rhythm, yet not for detecting note duration; perhaps I could do both. An example may be viewed here:



Third, I'm using Java, is ~10 milliseconds sleep at a rate of 18 FPS plausible for a user? 1000. / 18. = 55.55556; If I were to release this to the phone market, Would it consume too much battery power? Would it get out of sync? I have a 3GHZ processor; most ARM processors are only ~1GHZ. It seems that java would load balance on my PC. Does the same thing happen on a phone? Is native code ( C/C++) even quicker than Java?
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top