anchor.diff:  (defclass mnist-rbm (rbm) ())
   
   (defmethod set-input (samples (rbm mnist-rbm))
  -  (let ((inputs (find 'inputs (visible-chunks rbm)
  -                      :key #'name)))
  +  (let ((inputs (find 'inputs (visible-chunks rbm) :key #'name)))
       (when inputs
         (clamp-images samples (nodes inputs)))))
   
  
positive.code:       (dotimes (x 28)
          (princ (if (< 0.5 (aref a (+ (* y 28) x))) #\O #\.)))
        (terpri))))
  
  #+nil
  (dotimes (i 100)
    (print-image-array (image-array (aref (training-images) i)))
    (print (image-label (aref (training-images) i)))
    (terpri))
  
  (defun read-image-arrays (stream)
    (read-magic-or-lose stream 2051)
  
negative.code:                               :target expectations))
      (ce-error (->error :x predictions))))
  
  (defun train-mnist/4 (&key (training *training*) (test *test*) quick-run-p
                        bpn-var bpn-filename)
    (let ((bpn nil))
      (setq* (bpn bpn-var) (build-maxout-mnist-bpn))
      (init-bpn-weights bpn :stddev 0.01)
      (train-mnist-bpn-gd bpn training test
                          :n-softmax-epochs 0
                          :n-epochs (if quick-run-p 2 3000)
                          :learning-rate (flt 1)
                          :learning-rate-decay (flt 0.998)
                          :l2-upper-bound (sqrt (flt 3.75)))
      (unless quick-run-p
        (save-weights bpn-filename bpn))))
  
  #|
  
  (defvar *dbn/1*)
  (defvar *bpn/1*)
  
  (defparameter *mnist-1-dbn-filename*
    (merge-pathnames "mnist-1.dbn" *mnist-save-dir*))
  
  (defparameter *mnist-1-bpn-filename*
    (merge-pathnames "mnist-1.bpn" *mnist-save-dir*))
  
  (defparameter *mnist-1-dropout-bpn-filename*
    (merge-pathnames "mnist-1-dropout.bpn" *mnist-save-dir*))
  
  (with-cuda ()
    (let ((*random-state* (sb-ext:seed-random-state 983274)))
      (train-mnist/1 :training (training-images) :test (test-images)
                     :dbn-var '*dbn/1* :bpn-var '*bpn/1*
                     :dbn-filename *mnist-1-dbn-filename*
                     :bpn-filename *mnist-1-bpn-filename*)))
  
  (with-cuda ()
    (let ((*random-state* (sb-ext:seed-random-state 983274)))
      (train-mnist/1 :training (training-images) :test (test-images)
                     :load-dbn-p t :dropoutp t
                     :dbn-var '*dbn/1* :bpn-var '*bpn/1*
                     :dbn-filename *mnist-1-dbn-filename*
                     :bpn-filename *mnist-1-dropout-bpn-filename*)))
  
  (defvar *dbn/2*)
  (defvar *dbm/2*)
  (defvar *bpn/2*)
  
  (defparameter *mnist-2-dbn-filename*
    (merge-pathnames "mnist-2.dbn" *mnist-save-dir*))
  
  (defparameter *mnist-2-dbm-filename*
    (merge-pathnames "mnist-2.dbm" *mnist-save-dir*))
  
  (defparameter *mnist-2-bpn-filename*
    (merge-pathnames "mnist-2.bpn" *mnist-save-dir*))
  
  (defparameter *mnist-2-dropout-bpn-filename*
    (merge-pathnames "mnist-2-dropout.bpn" *mnist-save-dir*))
  
  (with-cuda ()
    (let ((*random-state* (sb-ext:seed-random-state 983274)))
      (train-mnist/2 :training (training-images) :test (test-images)
                     :dbn-var '*dbn/2* :dbm-var '*dbm/2* :bpn-var '*bpn/2*
                     :dbn-filename *mnist-2-dbn-filename*
                     :dbm-filename *mnist-2-dbm-filename*
                     :bpn-filename *mnist-2-bpn-filename*)))
  
  (with-cuda ()
    (let ((*random-state* (sb-ext:seed-random-state 983274)))
      (train-mnist/2 :training (training-images) :test (test-images)
                     :load-dbm-p t :dropoutp t
                     :dbn-var '*dbn/2* :dbm-var '*dbm/2* :bpn-var '*bpn/2*
                     :dbn-filename *mnist-2-dbn-filename*
                     :dbm-filename *mnist-2-dbm-filename*
                     :bpn-filename *mnist-2-dropout-bpn-filename*)))
  
  (defvar *bpn/3*)
  
  (defparameter *mnist-3-bpn-filename*
    (merge-pathnames "mnist-3.bpn" *mnist-save-dir*))
  
  
  (with-cuda ()
    (let ((*random-state* (sb-ext:seed-random-state 983274)))
      (train-mnist/3 :training (training-images) :test (test-images)
                     :bpn-var '*bpn/3* :bpn-filename *mnist-3-bpn-filename*)))
  
  (defvar *bpn/4*)
  
  (defparameter *mnist-4-bpn-filename*
    (merge-pathnames "mnist-4.bpn" *mnist-save-dir*))
  
  (with-cuda ()
    (let ((*random-state* (sb-ext:seed-random-state 983274)))
      (train-mnist/4 :training (training-images) :test (test-images)
                     :bpn-var '*bpn/4* :bpn-filename *mnist-4-bpn-filename*)))
  
  (require :sb-sprof)
  
  