Mercurial > ift6266
annotate deep/stacked_dae/v_sylvain/nist_apriori_error.py @ 423:e4eb3ee7a0cf
merge
author | Arnaud Bergeron <abergeron@gmail.com> |
---|---|
date | Fri, 30 Apr 2010 16:25:37 -0400 |
parents | fb028b37ce92 |
children | 5ca2936f2062 |
rev | line source |
---|---|
418
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
1 __docformat__ = 'restructedtext en' |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
2 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
3 import pdb |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
4 import numpy |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
5 from numpy import array |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
6 import time |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
7 import datetime |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
8 import pylearn |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
9 import copy |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
10 import sys |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
11 import os |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
12 import os.path |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
13 from pylearn.io import filetensor as ft |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
14 from jobman import DD |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
15 from ift6266 import datasets |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
16 import cPickle |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
17 from copy import copy |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
18 import math |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
19 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
20 from config import * |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
21 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
22 data_path = '/data/lisa/data/nist/by_class/' |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
23 test_data = 'all/all_train_data.ft' |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
24 test_labels = 'all/all_train_labels.ft' |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
25 state = DD(DEFAULT_HP_NIST) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
26 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
27 #sda_model -> path for the parameters file |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
28 #dataset -> the dataset we use for the test |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
29 #part -> 0=train, 1=valid, 2=test |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
30 #type -> non-linearity type 0=sigmoid, 1=tanh |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
31 def test_data(sda_model,dataset,part=2,type=0): |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
32 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
33 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
34 f = open(sda_model) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
35 parameters_pre=cPickle.load(f) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
36 f.close() |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
37 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
38 W1 = array(copy(parameters_pre[0])) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
39 #print 'W1: ' + str(W1.shape) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
40 b1 = array(copy(parameters_pre[1])) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
41 #print 'b1: ' + str(b1.shape) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
42 W2 = array(copy(parameters_pre[2])) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
43 #print 'W2: ' + str(W2.shape) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
44 b2 = array(copy(parameters_pre[3])) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
45 #print 'b2: ' + str(b2.shape) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
46 W3 = array(copy(parameters_pre[4])) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
47 #print 'W3: ' + str(W3.shape) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
48 b3 = array(copy(parameters_pre[5])) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
49 #print 'b3: ' + str(b3.shape) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
50 if state['num_hidden_layers'] == 4: |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
51 W4 = array(copy(parameters_pre[6])) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
52 b4 = array(copy(parameters_pre[7])) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
53 Wo = array(copy(parameters_pre[8])) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
54 bo = array(copy(parameters_pre[9])) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
55 elif state['num_hidden_layers'] == 3: |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
56 Wo = array(copy(parameters_pre[6])) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
57 #print 'Wo: ' + str(Wo.shape) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
58 bo = array(copy(parameters_pre[7])) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
59 #print 'bo: ' + str(bo.shape) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
60 W4=None |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
61 b4=None |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
62 else: |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
63 print('Number of layers not implemented yet, please do it') |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
64 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
65 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
66 total_error_count=0 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
67 total_exemple_count=0 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
68 if part == 0: |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
69 iter = dataset.train(1) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
70 if part == 1: |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
71 iter = dataset.valid(1) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
72 if part == 2: |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
73 iter = dataset.test(1) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
74 for x,y in iter: |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
75 total_exemple_count = total_exemple_count +1 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
76 if type == 1: |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
77 #get output for layer 1 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
78 out1=(numpy.tanh(numpy.dot(x,W1) + b1)+1.0)/2.0 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
79 #get output for layer 2 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
80 out2=(numpy.tanh(numpy.dot(out1,W2) + b2)+1.0)/2.0 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
81 #get output for layer 3 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
82 out3=(numpy.tanh(numpy.dot(out2,W3) + b3)+1.0)/2.0 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
83 #if there is a fourth layer |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
84 if state['num_hidden_layers'] == 4: |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
85 outf = (numpy.tanh(numpy.dot(out3,W4) + b4)+1.0)/2.0 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
86 else: |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
87 outf = array(out3) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
88 else: |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
89 #get output for layer 1 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
90 out1=1.0/(1.0+numpy.exp(-(numpy.dot(x,W1)+b1))) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
91 #get output for layer 2 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
92 out2 = 1.0/(1.0+numpy.exp(-(numpy.dot(out1,W2)+b2))) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
93 #get output for layer 3 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
94 out3 = 1.0/(1.0+numpy.exp(-(numpy.dot(out2,W3)+b3))) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
95 #if there is a fourth layer |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
96 if state['num_hidden_layers'] == 4: |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
97 outf = 1.0/(1.0+numpy.exp(-(numpy.dot(out3,W4)+b4))) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
98 else: |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
99 outf = out3 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
100 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
101 out_act = numpy.dot(outf,Wo)+bo |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
102 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
103 #add non linear function for output activation (softmax) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
104 #We can also use sigmoid and results will be the same |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
105 out = numpy.zeros(len(out_act[0]),float) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
106 a1_exp = numpy.exp(out_act) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
107 sum_a1=numpy.sum(a1_exp) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
108 out=a1_exp/sum_a1 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
109 ## for i in xrange(len(out_act[0])): |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
110 ## out[i]=sigmoid(array(out_act[0,i])) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
111 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
112 #get grouped based error |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
113 #with a priori |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
114 if(y>9 and y<35): |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
115 predicted_class=numpy.argmax(out[0,10:35])+10 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
116 if(predicted_class!=y): |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
117 total_error_count+=1 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
118 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
119 if(y<10): |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
120 predicted_class=numpy.argmax(out[0,0:10]) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
121 if(predicted_class!=y): |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
122 total_error_count+=1 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
123 if(y>34): |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
124 predicted_class=numpy.argmax(out[0,35:])+35 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
125 if(predicted_class!=y): |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
126 total_error_count+=1 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
127 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
128 print '\t total exemples count: '+str(total_exemple_count) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
129 print '\t total error count: '+str(total_error_count) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
130 print '\t percentage of error: '+str(total_error_count*100.0/total_exemple_count*1.0)+' %' |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
131 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
132 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
133 def sigmoid(value): |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
134 ## if len(value) > 1: |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
135 ## retour = numpy.zeros(len(value),float) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
136 ## for i in xrange(len(value)): |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
137 ## retour[i] = (1.0/(1.0+math.exp(-float(value[i])))) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
138 ## return retour |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
139 ## else: |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
140 ## print len(value) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
141 return (1.0/(1.0+math.exp(-value))) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
142 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
143 if __name__ == '__main__': |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
144 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
145 args = sys.argv[1:] |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
146 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
147 if len(args) > 0 and args[0] == 'sigmoid': |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
148 type = 0 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
149 elif len(args) > 0 and args[0] == 'tanh': |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
150 type = 1 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
151 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
152 part = 2 #0=train, 1=valid, 2=test |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
153 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
154 PATH = '' #Can be changed too if model is not in the current drectory |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
155 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
156 if os.path.exists(PATH+'params_finetune_NIST.txt'): |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
157 start_time = time.clock() |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
158 print ('\n finetune = NIST ') |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
159 print "NIST DIGITS" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
160 test_data(PATH+'params_finetune_NIST.txt',datasets.nist_digits(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
161 print "NIST LOWER CASE" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
162 test_data(PATH+'params_finetune_NIST.txt',datasets.nist_lower(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
163 print "NIST UPPER CASE" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
164 test_data(PATH+'params_finetune_NIST.txt',datasets.nist_upper(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
165 end_time = time.clock() |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
166 print ('It took %f minutes' %((end_time-start_time)/60.)) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
167 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
168 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
169 if os.path.exists(PATH+'params_finetune_P07.txt'): |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
170 start_time = time.clock() |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
171 print ('\n finetune = P07 ') |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
172 print "NIST DIGITS" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
173 test_data(PATH+'params_finetune_P07.txt',datasets.nist_digits(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
174 print "NIST LOWER CASE" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
175 test_data(PATH+'params_finetune_P07.txt',datasets.nist_lower(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
176 print "NIST UPPER CASE" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
177 test_data(PATH+'params_finetune_P07.txt',datasets.nist_upper(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
178 end_time = time.clock() |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
179 print ('It took %f minutes' %((end_time-start_time)/60.)) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
180 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
181 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
182 if os.path.exists(PATH+'params_finetune_NIST_then_P07.txt'): |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
183 start_time = time.clock() |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
184 print ('\n finetune = NIST then P07') |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
185 print "NIST DIGITS" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
186 test_data(PATH+'params_finetune_NIST_then_P07.txt',datasets.nist_digits(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
187 print "NIST LOWER CASE" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
188 test_data(PATH+'params_finetune_NIST_then_P07.txt',datasets.nist_lower(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
189 print "NIST UPPER CASE" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
190 test_data(PATH+'params_finetune_NIST_then_P07.txt',datasets.nist_upper(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
191 end_time = time.clock() |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
192 print ('It took %f minutes' %((end_time-start_time)/60.)) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
193 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
194 if os.path.exists(PATH+'params_finetune_P07_then_NIST.txt'): |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
195 start_time = time.clock() |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
196 print ('\n finetune = P07 then NIST') |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
197 print "NIST DIGITS" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
198 test_data(PATH+'params_finetune_P07_then_NIST.txt',datasets.nist_digits(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
199 print "NIST LOWER CASE" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
200 test_data(PATH+'params_finetune_P07_then_NIST.txt',datasets.nist_lower(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
201 print "NIST UPPER CASE" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
202 test_data(PATH+'params_finetune_P07_then_NIST.txt',datasets.nist_upper(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
203 end_time = time.clock() |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
204 print ('It took %f minutes' %((end_time-start_time)/60.)) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
205 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
206 if os.path.exists(PATH+'params_finetune_PNIST07.txt'): |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
207 start_time = time.clock() |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
208 print ('\n finetune = PNIST07') |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
209 print "NIST DIGITS" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
210 test_data(PATH+'params_finetune_PNIST07.txt',datasets.nist_digits(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
211 print "NIST LOWER CASE" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
212 test_data(PATH+'params_finetune_PNIST07.txt',datasets.nist_lower(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
213 print "NIST UPPER CASE" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
214 test_data(PATH+'params_finetune_PNIST07.txt',datasets.nist_upper(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
215 end_time = time.clock() |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
216 print ('It took %f minutes' %((end_time-start_time)/60.)) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
217 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
218 if os.path.exists(PATH+'params_finetune_PNIST07_then_NIST.txt'): |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
219 start_time = time.clock() |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
220 print ('\n finetune = PNIST07 then NIST') |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
221 print "NIST DIGITS" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
222 test_data(PATH+'params_finetune_PNIST07_then_NIST.txt',datasets.nist_digits(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
223 print "NIST LOWER CASE" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
224 test_data(PATH+'params_finetune_PNIST07_then_NIST.txt',datasets.nist_lower(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
225 print "NIST UPPER CASE" |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
226 test_data(PATH+'params_finetune_PNIST07_then_NIST.txt',datasets.nist_upper(),part=part,type=type) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
227 end_time = time.clock() |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
228 print ('It took %f minutes' %((end_time-start_time)/60.)) |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
229 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
230 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
231 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
232 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
233 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
234 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
235 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
236 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
237 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
238 |
fb028b37ce92
Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff
changeset
|
239 |