diff scripts/nist_read2.py @ 107:a9b87b68101d

Ajouté un script pour visualiser les ensembles de données générés enregistrés dans le format filetensor (nist_read2.py)
author boulanni <nicolas_boulanger@hotmail.com>
date Mon, 15 Feb 2010 15:35:17 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/nist_read2.py	Mon Feb 15 15:35:17 2010 -0500
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+
+from pylearn.io import filetensor as ft
+import pylab, numpy
+
+datapath = '/data/lisa/data/ift6266h10/train_'
+
+f = open(datapath+'data.ft')
+d = ft.read(f)
+
+f = open(datapath+'labels.ft')
+labels = ft.read(f)
+
+def label2chr(l):
+    if l<10:
+        return chr(l + ord('0'))
+    elif l<36:
+        return chr(l-10 + ord('A'))
+    else:
+        return chr(l-36 + ord('a'))
+
+for i in range(min(d.shape[0],30)):
+    pylab.figure()
+    pylab.title(label2chr(labels[i]))
+    pylab.imshow(d[i].reshape((32,32))/255., pylab.matplotlib.cm.Greys_r, interpolation='nearest')
+
+pylab.show()
+