public void processError(Vector error) { Matrix weightUpdate = error.times(lastInput.transpose()); layer.acceptNewWeightUpdate(weightUpdate); Vector biasUpdate = layer.getBiasVector().plus(error); layer.acceptNewBiasUpdate(biasUpdate); }
public static Matrix calculateWeightUpdates( LayerSensitivity layerSensitivity, Vector previousLayerActivationOrInput, double alpha) { Layer layer = layerSensitivity.getLayer(); Matrix activationTranspose = previousLayerActivationOrInput.transpose(); Matrix weightUpdateMatrix = layerSensitivity.getSensitivityMatrix() .times(activationTranspose).times(alpha).times(-1.0); layer.acceptNewWeightUpdate(weightUpdateMatrix.copy()); return(weightUpdateMatrix); }
public Matrix calculateWeightUpdates(LayerSensitivity layerSensitivity, Vector previousLayerActivationOrInput, double alpha, double momentum) { Layer layer = layerSensitivity.getLayer(); Matrix activationTranspose = previousLayerActivationOrInput.transpose(); Matrix momentumLessUpdate = layerSensitivity.getSensitivityMatrix() .times(activationTranspose).times(alpha).times(-1.0); Matrix updateWithMomentum = layer.getLastWeightUpdateMatrix().times( momentum).plus(momentumLessUpdate.times(1.0 - momentum)); layer.acceptNewWeightUpdate(updateWithMomentum.copy()); return(updateWithMomentum); }