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