anchor.diff:  
   
   ;;;; Code for the DBN to DBM to BPN approach (paper [2])
  +
  +(defclass mnist-rbm/2 (mnist-rbm) ())
  +
  +(defun clamp-labels (images chunk)
  +  (let ((nodes (storage (nodes chunk))))
  +    (loop for image in images
  +          for stripe upfrom 0
  +          do (destructuring-bind (image &key omit-label-p) image
  +               (unless omit-label-p
  +                 (with-stripes ((stripe chunk start end))
  +                   (fill nodes (flt 0) :start start :end end)
  +                   (setf (aref nodes (+ start (image-label image)))
  +                         #.(flt 1))))))))
  +
  +(defmethod set-input (images (rbm mnist-rbm/2))
  +  (call-next-method)
  +  (sample-visible rbm)
  +  (let ((label-chunk (find-chunk 'label rbm)))
  +    (when label-chunk
  +      (clamp-labels images label-chunk))))
  +
  +(defclass softmax-label-chunk* (softmax-label-chunk) ())
  +
  +(defmethod maybe-make-misclassification-measurer ((chunk softmax-label-chunk*))
  +  (let ((measurer (call-next-method)))
  +    (when measurer
  +      (lambda (examples)
  +        (funcall measurer (mapcar #'first examples))))))
   
   (defclass mnist-dbm (dbm)
     ((layers :initform (list
  
positive.code:     (setq *test-images* (load-test)))
    (flet ((train-dbn ()
             (init-mnist-dbn *dbn/2*)
             (train-mnist-dbn *dbn/2*)
             (save-weights (merge-pathnames "mnist-2.dbn" *mnist-dir*)
                           *dbn/2*))
  
negative.code: (defclass mnist-logging-trainer (logging-trainer) ())
  
  (defmethod log-training-period ((trainer mnist-logging-trainer) learner)
    1000)
  
  (defmethod log-test-period ((trainer mnist-logging-trainer) learner)
    10000 #+nil(length *training-images*))
  
  
  