Mercurial > ift6266
annotate scripts/nist_divide.py @ 130:38929c29b602
merge
author | Xavier Glorot <glorotxa@iro.umontreal.ca> |
---|---|
date | Thu, 18 Feb 2010 14:44:23 -0500 |
parents | d508f5a8acd0 |
children | 2b6a28e4cadc |
rev | line source |
---|---|
60
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
2 |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
3 ''' |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
4 creation des ensembles train, valid et test NIST pur |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
5 ensemble test est pris tel quel |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
6 ensemble valid est trainorig[:20000] |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
7 ensemble train est trainorig[20000:] |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
8 trainorig est deja shuffled |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
9 ''' |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
10 |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
11 from pylearn.io import filetensor as ft |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
12 import numpy, os |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
13 |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
14 dir1 = "/data/lisa/data/nist/by_class/all/" |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
15 dir2 = "/data/lisa/data/ift6266h10/" |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
16 |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
17 os.system("cp %s %s" % (dir1 + "all_test_data.ft", dir2 + "test_data.ft")) |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
18 os.system("cp %s %s" % (dir1 + "all_test_labels.ft", dir2 + "test_labels.ft")) |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
19 |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
20 f = open(dir1 + "/all_train_data.ft") |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
21 d = ft.read(f) |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
22 f = open(dir2 + "valid_data.ft", 'wb') |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
23 ft.write(f, d[:20000]) |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
24 f = open(dir2 + "train_data.ft", 'wb') |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
25 ft.write(f, d[20000:]) |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
26 |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
27 f = open(dir1 + "/all_train_labels.ft") |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
28 d = ft.read(f) |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
29 f = open(dir2 + "valid_labels.ft", 'wb') |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
30 ft.write(f, d[:20000]) |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
31 f = open(dir2 + "train_labels.ft", 'wb') |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
32 ft.write(f, d[20000:]) |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
33 |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
34 for i in ["train", "valid", "test"]: |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
35 os.chmod(dir2 + i + "_data.ft", 0744) |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
36 os.chmod(dir2 + i + "_labels.ft", 0744) |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
37 |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
38 |
d508f5a8acd0
Script pour creer ensembles train, valid et test NIST pur
boulanni <nicolas_boulanger@hotmail.com>
parents:
diff
changeset
|
39 |