*/
private Vector backPropagate(int currentLayerIndex, Vector nextLayerDelta,
List<Vector> outputCache, Matrix weightUpdateMatrix) {
// Get layer related information
final DoubleFunction derivativeSquashingFunction =
NeuralNetworkFunctions.getDerivativeDoubleFunction(squashingFunctionList.get(currentLayerIndex));
Vector curLayerOutput = outputCache.get(currentLayerIndex);
Matrix weightMatrix = weightMatrixList.get(currentLayerIndex);
Matrix prevWeightMatrix = prevWeightUpdatesList.get(currentLayerIndex);
// Next layer is not output layer, remove the delta of bias neuron
if (currentLayerIndex != 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) {