anchor.diff:  ;;;      (* WEIGHT-DECAY WEIGHTS))
   ;;;
   ;;; plus momentum, weight-penalty.
  -(defun update-all-weights (trainer)
  +(defun update-all-weights/nesterov (trainer)
     (map nil #'funcall (before-update-hook trainer))
     (let ((accumulator (accumulator trainer))
           (weight-deltas (weight-deltas trainer))
  
positive.code:         (dotimes (i (length weight-deltas))
            (decf (aref weight-deltas i) weight-penalty))))
      (with-shape-and-displacement (weight-deltas)
        (do-segment-set (segment :start-in-segment-set start-in-segment-set)
                        (segment-set trainer)
          (let ((weights (segment-weights segment)))
            (reshape-and-displace! weight-deltas (mat-size weights)
                                   start-in-segment-set)
            (unless (zerop weight-decay)
              (mgl-mat:axpy! weight-decay weights weight-deltas))
            (mgl-mat:axpy! (- learning-rate) weight-deltas weights))))
      (fill! (flt 0) accumulator)
      (setf (n-inputs-in-batch trainer) 0))
  
negative.code: (defmethod maybe-update-weights ((trainer batch-gd-trainer) n-new-inputs)
    (when (<= (batch-size trainer)
              (incf (n-inputs-in-batch trainer) n-new-inputs))
      (ecase (momentum-type trainer)
        ((:normal)
         (update-all-weights/normal trainer))
        ((:nesterov)
         (update-all-weights/nesterov trainer))))
    (incf (n-inputs trainer) n-new-inputs))
  
  ;;; delta_w' += m * delta_w + df/dw
  