this.v[vsptr + ivar] = 0.0;
this.w[wsptr + ivar] = 0.0;
}
}
final MLDataPair pair = BasicMLDataPair.createPair(this.network
.getSamples().getInputSize(), this.network.getSamples()
.getIdealSize());
for (int r = 0; r < this.network.getSamples().getRecordCount(); r++) {
this.network.getSamples().getRecord(r, pair);
if (r == this.network.getExclude()) {
continue;
}
dist = 0.0;
for (ivar = 0; ivar < this.network.getInputCount(); ivar++) {
diff = input.getData(ivar) - pair.getInput().getData(ivar);
diff /= this.network.getSigma()[ivar];
this.dsqr[ivar] = diff * diff;
dist += this.dsqr[ivar];
}
if (this.network.getKernel() == PNNKernelType.Gaussian) {
dist = Math.exp(-dist);
} else if (this.network.getKernel() == PNNKernelType.Reciprocal) {
dist = 1.0 / (1.0 + dist);
}
truedist = dist;
if (dist < 1.e-40) {
dist = 1.e-40;
}
if (this.network.getOutputMode() == PNNOutputMode.Classification) {
pop = (int) pair.getIdeal().getData(0);
out[pop] += dist;
vptr = pop * this.network.getInputCount();
wptr = pop * this.network.getInputCount();
for (ivar = 0; ivar < this.network.getInputCount(); ivar++) {
temp = truedist * this.dsqr[ivar];
this.v[vptr + ivar] += temp;
this.w[wptr + ivar] += temp * (2.0 * this.dsqr[ivar] - 3.0);
}
}
else if (this.network.getOutputMode() == PNNOutputMode.Unsupervised) {
for (ivar = 0; ivar < this.network.getInputCount(); ivar++) {
out[ivar] += dist * pair.getInput().getData(ivar);
temp = truedist * this.dsqr[ivar];
this.v[vsptr + ivar] += temp;
this.w[wsptr + ivar] += temp
* (2.0 * this.dsqr[ivar] - 3.0);
}
vptr = 0;
wptr = 0;
for (outvar = 0; outvar < this.network.getOutputCount(); outvar++) {
for (ivar = 0; ivar < this.network.getInputCount(); ivar++) {
temp = truedist * this.dsqr[ivar]
* pair.getInput().getData(ivar);
this.v[vptr++] += temp;
this.w[wptr++] += temp * (2.0 * this.dsqr[ivar] - 3.0);
}
}
psum += dist;
} else if (this.network.getOutputMode() == PNNOutputMode.Regression) {
for (ivar = 0; ivar < this.network.getOutputCount(); ivar++) {
out[ivar] += dist * pair.getIdeal().getData(ivar);
}
vptr = 0;
wptr = 0;
for (outvar = 0; outvar < this.network.getOutputCount(); outvar++) {
for (ivar = 0; ivar < this.network.getInputCount(); ivar++) {
temp = truedist * this.dsqr[ivar]
* pair.getIdeal().getData(outvar);
this.v[vptr++] += temp;
this.w[wptr++] += temp * (2.0 * this.dsqr[ivar] - 3.0);
}
}
for (ivar = 0; ivar < this.network.getInputCount(); ivar++) {