comparison deep/stacked_dae/v_sylvain/nist_byclass_error.py @ 398:eb42bed0c13b

Sert pour calculer les erreurs de test sur les differentes parties de NIST pour un modele donne
author SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
date Tue, 27 Apr 2010 20:54:28 -0400
parents
children 9fb893d039c6
comparison
equal deleted inserted replaced
397:5e11dda78995 398:eb42bed0c13b
1 #!/usr/bin/python
2 # coding: utf-8
3
4 import ift6266
5 import pylearn
6
7 import numpy
8 import theano
9 import time
10
11 import pylearn.version
12 import theano.tensor as T
13 from theano.tensor.shared_randomstreams import RandomStreams
14
15 import copy
16 import sys
17 import os
18 import os.path
19
20 from jobman import DD
21 import jobman, jobman.sql
22 from pylearn.io import filetensor
23
24 from utils import produit_cartesien_jobs
25 from copy import copy
26
27 from sgd_optimization import SdaSgdOptimizer
28
29 #from ift6266.utils.scalar_series import *
30 from ift6266.utils.seriestables import *
31 import tables
32
33 from ift6266 import datasets
34 from config import *
35
36 '''
37 Function called by jobman upon launching each job
38 Its path is the one given when inserting jobs: see EXPERIMENT_PATH
39 '''
40 def jobman_entrypoint(state, channel):
41 # record mercurial versions of each package
42 pylearn.version.record_versions(state,[theano,ift6266,pylearn])
43 # TODO: remove this, bad for number of simultaneous requests on DB
44 channel.save()
45
46 # For test runs, we don't want to use the whole dataset so
47 # reduce it to fewer elements if asked to.
48 rtt = None
49 if state.has_key('reduce_train_to'):
50 rtt = state['reduce_train_to']
51 elif REDUCE_TRAIN_TO:
52 rtt = REDUCE_TRAIN_TO
53
54 n_ins = 32*32
55 n_outs = 62 # 10 digits, 26*2 (lower, capitals)
56
57 examples_per_epoch = NIST_ALL_TRAIN_SIZE
58
59 PATH = ''
60
61
62
63 print "Creating optimizer with state, ", state
64
65 optimizer = SdaSgdOptimizer(dataset=datasets.nist_all(),
66 hyperparameters=state, \
67 n_ins=n_ins, n_outs=n_outs,\
68 examples_per_epoch=examples_per_epoch, \
69 max_minibatches=rtt)
70
71
72
73
74
75 if os.path.exists(PATH+'params_finetune_NIST.txt'):
76 print ('\n finetune = NIST ')
77 optimizer.reload_parameters(PATH+'params_finetune_NIST.txt')
78 print "NIST DIGITS"
79 optimizer.training_error(datasets.nist_digits(),part=2)
80 print "NIST LOWER CASE"
81 optimizer.training_error(datasets.nist_lower(),part=2)
82 print "NIST UPPER CASE"
83 optimizer.training_error(datasets.nist_upper(),part=2)
84
85
86 if os.path.exists(PATH+'params_finetune_P07.txt'):
87 print ('\n finetune = P07 ')
88 optimizer.reload_parameters(PATH+'params_finetune_P07.txt')
89 print "NIST DIGITS"
90 optimizer.training_error(datasets.nist_digits(),part=2)
91 print "NIST LOWER CASE"
92 optimizer.training_error(datasets.nist_lower(),part=2)
93 print "NIST UPPER CASE"
94 optimizer.training_error(datasets.nist_upper(),part=2)
95
96
97 if os.path.exists(PATH+'params_finetune_NIST_then_P07.txt'):
98 print ('\n finetune = NIST then P07')
99 optimizer.reload_parameters(PATH+'params_finetune_NIST_then_P07.txt')
100 print "NIST DIGITS"
101 optimizer.training_error(datasets.nist_digits(),part=2)
102 print "NIST LOWER CASE"
103 optimizer.training_error(datasets.nist_lower(),part=2)
104 print "NIST UPPER CASE"
105 optimizer.training_error(datasets.nist_upper(),part=2)
106
107 if os.path.exists(PATH+'params_finetune_P07_then_NIST.txt'):
108 print ('\n finetune = P07 then NIST')
109 optimizer.reload_parameters(PATH+'params_finetune_P07_then_NIST.txt')
110 print "NIST DIGITS"
111 optimizer.training_error(datasets.nist_digits(),part=2)
112 print "NIST LOWER CASE"
113 optimizer.training_error(datasets.nist_lower(),part=2)
114 print "NIST UPPER CASE"
115 optimizer.training_error(datasets.nist_upper(),part=2)
116
117 if os.path.exists(PATH+'params_finetune_PNIST07.txt'):
118 print ('\n finetune = PNIST07')
119 optimizer.reload_parameters(PATH+'params_finetune_PNIST07.txt')
120 print "NIST DIGITS"
121 optimizer.training_error(datasets.nist_digits(),part=2)
122 print "NIST LOWER CASE"
123 optimizer.training_error(datasets.nist_lower(),part=2)
124 print "NIST UPPER CASE"
125 optimizer.training_error(datasets.nist_upper(),part=2)
126
127 if os.path.exists(PATH+'params_finetune_PNIST07_then_NIST.txt'):
128 print ('\n finetune = PNIST07 then NIST')
129 optimizer.reload_parameters(PATH+'params_finetune_PNIST07_then_NIST.txt')
130 print "NIST DIGITS"
131 optimizer.training_error(datasets.nist_digits(),part=2)
132 print "NIST LOWER CASE"
133 optimizer.training_error(datasets.nist_lower(),part=2)
134 print "NIST UPPER CASE"
135 optimizer.training_error(datasets.nist_upper(),part=2)
136
137 channel.save()
138
139 return channel.COMPLETE
140
141
142
143 if __name__ == '__main__':
144
145
146 chanmock = DD({'COMPLETE':0,'save':(lambda:None)})
147 jobman_entrypoint(DD(DEFAULT_HP_NIST), chanmock)
148
149