Bug in nutils.py?

40 views
Skip to first unread message

berti...@gmail.com

unread,
Aug 15, 2013, 10:41:54 AM8/15/13
to ocr...@googlegroups.com
Maybe I found a bug in ocrolib/nutils.py.

The function to be compiled and used during training:

void sumprod(int r,int n,double u[r][n],double v[r][n],double a[n]) {
    for(int i=0;i<n;i++) {
        double total = 0.0;
        for(int k=0;k<r;k++) total += u[k][i]*v[k][i];
        a[i] = total;
    }
}

Python wrapper:

lstm_native.sumprod.argtypes = [I,I,A1D,A2D,A2D]
def sumprod(u,v,out=None):
    assert out.shape==u.shape[1:] and out.shape==v.shape[1:] and u.shape[:1]==v.shape[:1]
    lstm_native.sumprod(len(u),len(out),out,u,v)
    return out


But I think the Python wrapper should be

lstm_native.sumprod.argtypes = [I,I,A2D,A2D,A1D]
def sumprod(u,v,out=None):
    assert out.shape==u.shape[1:] and out.shape==v.shape[1:] and u.shape[:1]==v.shape[:1]
    lstm_native.sumprod(len(u),len(out),u,v,out)
    return out


This made my training process crash. And even if it does not crash, it should lead to wrong results, shouldn't it?

Regards

berti...@gmail.com

unread,
Aug 15, 2013, 10:44:25 AM8/15/13
to ocr...@googlegroups.com
By the way, I am talking about version 0.7.
Reply all
Reply to author
Forward
0 new messages