*/
private Vector backPropagate(int curLayerIdx, Vector nextLayerDelta,
List<Vector> outputCache, Matrix weightUpdateMatrix) {
// get layer related information
final DoubleFunction derivativeSquashingFunction =
NeuralNetworkFunctions.getDerivativeDoubleFunction(this.squashingFunctionList.get(curLayerIdx));
Vector curLayerOutput = outputCache.get(curLayerIdx);
Matrix weightMatrix = this.weightMatrixList.get(curLayerIdx);
Matrix prevWeightMatrix = this.prevWeightUpdatesList.get(curLayerIdx);
// next layer is not output layer, remove the delta of bias neuron
if (curLayerIdx != this.layerSizeList.size() - 2) {
nextLayerDelta = nextLayerDelta.viewPart(1, nextLayerDelta.size() - 1);
}
Vector delta = weightMatrix.transpose().times(nextLayerDelta);
delta = delta.assign(curLayerOutput, new DoubleDoubleFunction() {
@Override
public double apply(double deltaElem, double curLayerOutputElem) {
return deltaElem * derivativeSquashingFunction.apply(curLayerOutputElem);
}
});
// update weights
for (int i = 0; i < weightUpdateMatrix.rowSize(); ++i) {