Devon,

If it’s just MNIST data you need, I was able to reformat files from 
http://yann.lecun.com/exdb/mnist/ <http://yann.lecun.com/exdb/mnist/> quite 
satisfactorily.

I used Dyalog APL and did actually write up the format as a pdf file. The 
function I used went like this:

r←read file;⎕IO;tn;d;magic;count;rows;cols

 ⍝ Retrieves file contents.

 tn←⍬ ⋄ ⎕IO←0 ⋄ r←⍬
 :Trap 0⍴0
     ⍝ Read the file's contents as bits
     tn←file ⎕NTIE 0
     r←⎕NREAD tn,11,2↑⎕NSIZE tn
     ⎕NUNTIE tn
     magic←2⊥32⍴r
     count←2⊥32⍴32↓r
     :If magic=2051
         rows←2⊥32⍴64↓r
         cols←2⊥32⍴96↓r
         r←2⊥1 2 3 0⍉(count,rows,cols,8)⍴128↓r
     :ElseIf magic=2049
         r←2⊥1 0⍉(count,8)⍴64↓r
     :EndIf
 :Else
     ⎕NUNTIE tn
 :EndTrap

If you’d like the PDF, let me know.

Mike


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to