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

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
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.
 
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?