Menu

#6 BUG Report: computeNewPhi in Inferencer.java

v1.0_(example)
open
Bug Report (1)
5
2015-10-12
2015-10-12
No

There might be a bug in the function computeNewPhi() in Inferencer.java:

The original codes:

protected void computeNewPhi(){
        for (int k = 0; k < newModel.K; k++){
            for (int _w = 0; _w < newModel.V; _w++){
                Integer id = newModel.data.lid2gid.get(_w);

                if (id != null){
                    newModel.phi[k][_w] = (trnModel.nw[id][k] + newModel.nw[_w][k] + newModel.beta) / (newModel.nwsum[k] + newModel.nwsum[k] + trnModel.V * newModel.beta);
                }
            }//end foreach word
        }// end foreach topic
    }

The denominator includes two newModel.nwsum[k] that may be replaced by the sum of newModel.nwsum[k] and trnModel.nwsum[k] as follows:

The modified codes:

protected void computeNewPhi(){
        for (int k = 0; k < newModel.K; k++){
            for (int _w = 0; _w < newModel.V; _w++){
                Integer id = newModel.data.lid2gid.get(_w);

                if (id != null){
                    newModel.phi[k][_w] = (trnModel.nw[id][k] + newModel.nw[_w][k] + newModel.beta) / (trnModel.nwsum[k] + newModel.nwsum[k] + trnModel.V * newModel.beta);
                }
            }//end foreach word
        }// end foreach topic
    }

The modified version as above performed better than the original version in my test with 12000+ documents.

Discussion


Log in to post a comment.

Monday.com Logo