anchor.diff:        (loop for i upfrom start below end
               do (setf (aref array i) (flt (* deviation (gaussian-random-1))))))))
   
  -(defun train-mnist-bpn (bpn &key (batch-size
  -                                  (min (length *training-images*) 1000))
  +(defun train-mnist-bpn (bpn training test &key
  +                        (batch-size (min (length training) 1000))
                           (n-softmax-epochs 5) n-epochs)
     (log-msg "Starting to train the softmax layer of BPN~%")
  -  (train (make-sampler *training-images*
  -                       :max-n (* n-softmax-epochs (length *training-images*))
  +  (train (make-sampler training
  +                       :max-n (* n-softmax-epochs (length training))
                          :omit-label-p t)
            (make-instance 'mnist-cg-bp-trainer
  +                        :training training
  +                        :test test
                           :cg-args (list :max-n-line-searches 3)
                           :batch-size batch-size
                           :segment-filter
  
positive.code: (defmethod log-test-error ((trainer mnist-rbm-trainer) learner)
    (call-next-method)
    (let ((rbm (rbm learner)))
      (log-dbn-cesc-accuracy rbm (make-training-sampler)
                             "training reconstruction")
      (log-dbn-cesc-accuracy rbm (make-training-sampler :omit-label-p t)
                             "training")
      (map nil (lambda (counter)
                 (log-msg "dbn test: ~:_test ~:_~A~%" counter))
           (collect-dbn-mean-field-errors/labeled
            (make-test-sampler) (dbn rbm) :rbm rbm
            :counters-and-measurers
            (make-dbn-reconstruction-rmse-counters-and-measurers
             (dbn rbm) :rbm rbm)))
      (log-dbn-cesc-accuracy rbm (make-test-sampler :omit-label-p t) "test")
      (log-msg "---------------------------------------------------~%")))
  
  
  ;;;; DBN training
  
  (defclass mnist-rbm-segment-trainer (batch-gd-trainer) ())
  
  (defmethod learning-rate ((trainer mnist-rbm-segment-trainer))
    (let ((x (slot-value trainer 'learning-rate)))
  
negative.code:   (/ (slot-value trainer 'learning-rate)
       (min (flt 10)
            (expt 1.000015
                  (* (/ (n-inputs trainer) (n-inputs-in-epoch trainer))
                     600)))))
  
  (defmethod momentum ((trainer mnist-dbm-segment-trainer))
    (if (< (n-inputs trainer) (* 5 (n-inputs-in-epoch trainer)))
        #.(flt 0.5)
        #.(flt 0.9)))
  
  