comparison 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
comparison
equal deleted inserted replaced
106:313c249d638e 107:a9b87b68101d
1 #!/usr/bin/env python
2
3 from pylearn.io import filetensor as ft
4 import pylab, numpy
5
6 datapath = '/data/lisa/data/ift6266h10/train_'
7
8 f = open(datapath+'data.ft')
9 d = ft.read(f)
10
11 f = open(datapath+'labels.ft')
12 labels = ft.read(f)
13
14 def label2chr(l):
15 if l<10:
16 return chr(l + ord('0'))
17 elif l<36:
18 return chr(l-10 + ord('A'))
19 else:
20 return chr(l-36 + ord('a'))
21
22 for i in range(min(d.shape[0],30)):
23 pylab.figure()
24 pylab.title(label2chr(labels[i]))
25 pylab.imshow(d[i].reshape((32,32))/255., pylab.matplotlib.cm.Greys_r, interpolation='nearest')
26
27 pylab.show()
28