I anticipate that is a quite precise question about how weight adaptation was implemented in the version 1.4 of BCI2000.
In particular the piece of code I want to discuss is this:
Code: Select all
predicted= 0;
for( i=0;i<nh;i++) // apply filter
{
predicted+= wt_buf[chan][i] * elements[i];
}
predicted-= sig_mean[chan]; // include mean in model
err= (float)target - predicted;
for(i=0;i<nh;i++) // update weights
{
wt_buf[chan][i]+= elements[i] * err * rate;
}
Since I am re-implementing this feature in BCI2000 2.0, I want to be sure to have understood how it worked in the past.
Form past discussions, I got that the weights were updated using a gradient descent algorithm, and precisely using the delta rule.
Reading the old manual of BCI2000 and looking to the source code what I have understood is that:
- you compute the value of the linear equation at the current step
Code: Select all
for( i=0;i<nh;i++) // apply filter
{
predicted+= wt_buf[chan][i] * elements[i];
}
- you compute the error by the difference of the firsts two
Code: Select all
err= (float)target - predicted;
Code: Select all
for(i=0;i<nh;i++) // update weights
{
wt_buf[chan][i]+= elements[i] * err * rate;
}
Now, since we want to have comparable values when we compute the error, we want "predicted" to be something like "target".
My idea is that "predicted" should be normalized using current values of gain and offset from the normalizer. This way "predicted" is transformed into a signal at zero mean and unit variance.
In the code I pasted above there is a normalization wrt mean at this line:
Code: Select all
predicted-= sig_mean[chan]; // include mean in model
And what about the feature value? is the value of
Code: Select all
elements[i]I'm asking this because when I debug my code it happens that the feature has a value like 200-300 and it seems strange that this kind of value (even if it is multiplied with "error" and a small learning rate) is summed up to the weights that are very small in absolute value.
I'm not sure I have explained my doubts clearly, neither that you can answer to such detailed questions about the code... but any kind of suggestion will be very appreciated.
Thanks a lot for your helpfulness.
Tiziano
