-
Notifications
You must be signed in to change notification settings - Fork 101
Open
Description
Hello !
I'm refactoring a bit nn.c/h and I think I found a mistake in the calculation of the matrix index for weight, gradient, sgradient, pgradient and delta:
#define WEIGHT(net,l,i,j) (net)->layer[l].weight[((j)*(net)->layer[l].units)+(i)]
#define GRADIENT(net,l,i,j) (net)->layer[l].gradient[((j)*(net)->layer[l].units)+(i)]
#define SGRADIENT(net,l,i,j) (net)->layer[l].sgradient[((j)*(net)->layer[l].units)+(i)]
#define PGRADIENT(net,l,i,j) (net)->layer[l].pgradient[((j)*(net)->layer[l].units)+(i)]
#define DELTA(net,l,i,j) (net)->layer[l].delta[((j)*(net)->layer[l].units)+(i)]
Looking at the allocation code for them it seems that the correct way to index is to multiply "units" by "i" and then add "j":
#define WEIGHT(net,l,i,j) (net)->layer[l].weight[((i)*(net)->layer[l].units)+(j)]
...
Attached are the refactored nn.c/h so far (compiles but doesn't seem to work properly).
The idea is to allocate units rounded up by SIMDF for alignment and be able to do full calculations directly using simd without left overs.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels