comparison deep/stacked_dae/v_sylvain/nist_byclass_error.py @ 446:9fb893d039c6

Ajout de fonctionnalite pour calculer les erreurs de validation avec PNIST et P07
author SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
date Tue, 04 May 2010 19:59:14 -0400
parents eb42bed0c13b
children
comparison
equal deleted inserted replaced
445:868f82777839 446:9fb893d039c6
55 n_outs = 62 # 10 digits, 26*2 (lower, capitals) 55 n_outs = 62 # 10 digits, 26*2 (lower, capitals)
56 56
57 examples_per_epoch = NIST_ALL_TRAIN_SIZE 57 examples_per_epoch = NIST_ALL_TRAIN_SIZE
58 58
59 PATH = '' 59 PATH = ''
60 NIST_BY_CLASS=0
60 61
61 62
62 63
63 print "Creating optimizer with state, ", state 64 print "Creating optimizer with state, ", state
64 65
73 74
74 75
75 if os.path.exists(PATH+'params_finetune_NIST.txt'): 76 if os.path.exists(PATH+'params_finetune_NIST.txt'):
76 print ('\n finetune = NIST ') 77 print ('\n finetune = NIST ')
77 optimizer.reload_parameters(PATH+'params_finetune_NIST.txt') 78 optimizer.reload_parameters(PATH+'params_finetune_NIST.txt')
78 print "NIST DIGITS" 79 if NIST_BY_CLASS == 1:
79 optimizer.training_error(datasets.nist_digits(),part=2) 80 print "NIST DIGITS"
80 print "NIST LOWER CASE" 81 optimizer.training_error(datasets.nist_digits(),part=2)
81 optimizer.training_error(datasets.nist_lower(),part=2) 82 print "NIST LOWER CASE"
82 print "NIST UPPER CASE" 83 optimizer.training_error(datasets.nist_lower(),part=2)
83 optimizer.training_error(datasets.nist_upper(),part=2) 84 print "NIST UPPER CASE"
85 optimizer.training_error(datasets.nist_upper(),part=2)
86 else:
87 print "P07 valid"
88 optimizer.training_error(datasets.nist_P07(),part=1)
89 print "PNIST valid"
90 optimizer.training_error(datasets.PNIST07(),part=1)
84 91
85 92
86 if os.path.exists(PATH+'params_finetune_P07.txt'): 93 if os.path.exists(PATH+'params_finetune_P07.txt'):
87 print ('\n finetune = P07 ') 94 print ('\n finetune = P07 ')
88 optimizer.reload_parameters(PATH+'params_finetune_P07.txt') 95 optimizer.reload_parameters(PATH+'params_finetune_P07.txt')
89 print "NIST DIGITS" 96 if NIST_BY_CLASS == 1:
90 optimizer.training_error(datasets.nist_digits(),part=2) 97 print "NIST DIGITS"
91 print "NIST LOWER CASE" 98 optimizer.training_error(datasets.nist_digits(),part=2)
92 optimizer.training_error(datasets.nist_lower(),part=2) 99 print "NIST LOWER CASE"
93 print "NIST UPPER CASE" 100 optimizer.training_error(datasets.nist_lower(),part=2)
94 optimizer.training_error(datasets.nist_upper(),part=2) 101 print "NIST UPPER CASE"
102 optimizer.training_error(datasets.nist_upper(),part=2)
103 else:
104 print "P07 valid"
105 optimizer.training_error(datasets.nist_P07(),part=1)
106 print "PNIST valid"
107 optimizer.training_error(datasets.PNIST07(),part=1)
95 108
96 109
97 if os.path.exists(PATH+'params_finetune_NIST_then_P07.txt'): 110 if os.path.exists(PATH+'params_finetune_NIST_then_P07.txt'):
98 print ('\n finetune = NIST then P07') 111 print ('\n finetune = NIST then P07')
99 optimizer.reload_parameters(PATH+'params_finetune_NIST_then_P07.txt') 112 optimizer.reload_parameters(PATH+'params_finetune_NIST_then_P07.txt')
100 print "NIST DIGITS" 113 if NIST_BY_CLASS == 1:
101 optimizer.training_error(datasets.nist_digits(),part=2) 114 print "NIST DIGITS"
102 print "NIST LOWER CASE" 115 optimizer.training_error(datasets.nist_digits(),part=2)
103 optimizer.training_error(datasets.nist_lower(),part=2) 116 print "NIST LOWER CASE"
104 print "NIST UPPER CASE" 117 optimizer.training_error(datasets.nist_lower(),part=2)
105 optimizer.training_error(datasets.nist_upper(),part=2) 118 print "NIST UPPER CASE"
119 optimizer.training_error(datasets.nist_upper(),part=2)
120 else:
121 print "P07 valid"
122 optimizer.training_error(datasets.nist_P07(),part=1)
123 print "PNIST valid"
124 optimizer.training_error(datasets.PNIST07(),part=1)
106 125
107 if os.path.exists(PATH+'params_finetune_P07_then_NIST.txt'): 126 if os.path.exists(PATH+'params_finetune_P07_then_NIST.txt'):
108 print ('\n finetune = P07 then NIST') 127 print ('\n finetune = P07 then NIST')
109 optimizer.reload_parameters(PATH+'params_finetune_P07_then_NIST.txt') 128 optimizer.reload_parameters(PATH+'params_finetune_P07_then_NIST.txt')
110 print "NIST DIGITS" 129 if NIST_BY_CLASS == 1:
111 optimizer.training_error(datasets.nist_digits(),part=2) 130 print "NIST DIGITS"
112 print "NIST LOWER CASE" 131 optimizer.training_error(datasets.nist_digits(),part=2)
113 optimizer.training_error(datasets.nist_lower(),part=2) 132 print "NIST LOWER CASE"
114 print "NIST UPPER CASE" 133 optimizer.training_error(datasets.nist_lower(),part=2)
115 optimizer.training_error(datasets.nist_upper(),part=2) 134 print "NIST UPPER CASE"
135 optimizer.training_error(datasets.nist_upper(),part=2)
136 else:
137 print "P07 valid"
138 optimizer.training_error(datasets.nist_P07(),part=1)
139 print "PNIST valid"
140 optimizer.training_error(datasets.PNIST07(),part=1)
116 141
117 if os.path.exists(PATH+'params_finetune_PNIST07.txt'): 142 if os.path.exists(PATH+'params_finetune_PNIST07.txt'):
118 print ('\n finetune = PNIST07') 143 print ('\n finetune = PNIST07')
119 optimizer.reload_parameters(PATH+'params_finetune_PNIST07.txt') 144 optimizer.reload_parameters(PATH+'params_finetune_PNIST07.txt')
120 print "NIST DIGITS" 145 if NIST_BY_CLASS == 1:
121 optimizer.training_error(datasets.nist_digits(),part=2) 146 print "NIST DIGITS"
122 print "NIST LOWER CASE" 147 optimizer.training_error(datasets.nist_digits(),part=2)
123 optimizer.training_error(datasets.nist_lower(),part=2) 148 print "NIST LOWER CASE"
124 print "NIST UPPER CASE" 149 optimizer.training_error(datasets.nist_lower(),part=2)
125 optimizer.training_error(datasets.nist_upper(),part=2) 150 print "NIST UPPER CASE"
151 optimizer.training_error(datasets.nist_upper(),part=2)
152 else:
153 print "P07 valid"
154 optimizer.training_error(datasets.nist_P07(),part=1)
155 print "PNIST valid"
156 optimizer.training_error(datasets.PNIST07(),part=1)
126 157
127 if os.path.exists(PATH+'params_finetune_PNIST07_then_NIST.txt'): 158 if os.path.exists(PATH+'params_finetune_PNIST07_then_NIST.txt'):
128 print ('\n finetune = PNIST07 then NIST') 159 print ('\n finetune = PNIST07 then NIST')
129 optimizer.reload_parameters(PATH+'params_finetune_PNIST07_then_NIST.txt') 160 optimizer.reload_parameters(PATH+'params_finetune_PNIST07_then_NIST.txt')
130 print "NIST DIGITS" 161 if NIST_BY_CLASS == 1:
131 optimizer.training_error(datasets.nist_digits(),part=2) 162 print "NIST DIGITS"
132 print "NIST LOWER CASE" 163 optimizer.training_error(datasets.nist_digits(),part=2)
133 optimizer.training_error(datasets.nist_lower(),part=2) 164 print "NIST LOWER CASE"
134 print "NIST UPPER CASE" 165 optimizer.training_error(datasets.nist_lower(),part=2)
135 optimizer.training_error(datasets.nist_upper(),part=2) 166 print "NIST UPPER CASE"
167 optimizer.training_error(datasets.nist_upper(),part=2)
168 else:
169 print "P07 valid"
170 optimizer.training_error(datasets.nist_P07(),part=1)
171 print "PNIST valid"
172 optimizer.training_error(datasets.PNIST07(),part=1)
136 173
137 channel.save() 174 channel.save()
138 175
139 return channel.COMPLETE 176 return channel.COMPLETE
140 177