Пример #1
0
 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;
 }
Пример #2
0
 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;
 }