annotate deep/stacked_dae/v_sylvain/nist_apriori_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 5ca2936f2062
children b2a7d93caa0f
rev   line source
439
5ca2936f2062 Bug fix in per-class a priori error : should be lower than before for both upper and lower
Guillaume Sicard <guitch21@gmail.com>
parents: 418
diff changeset
1 # -*- coding: utf-8 -*-
418
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
2 __docformat__ = 'restructedtext en'
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
3
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
4 import pdb
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
5 import numpy
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
6 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
7 import time
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
8 import datetime
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
9 import pylearn
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
10 import copy
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
11 import sys
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
12 import os
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
13 import os.path
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
14 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
15 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
16 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
17 import cPickle
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
18 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
19 import math
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
20
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
21 from config import *
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
22
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
23 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
24 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
25 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
26 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
27
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
28 #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
29 #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
30 #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
31 #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
32 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
33
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
34
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
35 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
36 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
37 f.close()
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
38
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
39 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
40 #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
41 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
42 #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
43 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
44 #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
45 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
46 #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
47 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
48 #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
49 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
50 #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
51 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
52 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
53 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
54 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
55 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
56 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
57 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
58 #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
59 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
60 #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
61 W4=None
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
62 b4=None
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
63 else:
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
64 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
65
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
66
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
67 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
68 total_exemple_count=0
439
5ca2936f2062 Bug fix in per-class a priori error : should be lower than before for both upper and lower
Guillaume Sicard <guitch21@gmail.com>
parents: 418
diff changeset
69 total_error_count_wap=0
5ca2936f2062 Bug fix in per-class a priori error : should be lower than before for both upper and lower
Guillaume Sicard <guitch21@gmail.com>
parents: 418
diff changeset
70
418
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
71 if part == 0:
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
72 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
73 if part == 1:
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
74 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
75 if part == 2:
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
76 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
77 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
78 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
79 if type == 1:
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
80 #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
81 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
82 #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
83 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
84 #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
85 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
86 #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
87 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
88 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
89 else:
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
90 outf = array(out3)
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
91 else:
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
92 #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
93 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
94 #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
95 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
96 #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
97 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
98 #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
99 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
100 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
101 else:
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
102 outf = out3
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
103
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
104 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
105
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
106 #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
107 #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
108 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
109 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
110 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
111 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
112 ## 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
113 ## 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
114
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
115 #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
116 #with a priori
439
5ca2936f2062 Bug fix in per-class a priori error : should be lower than before for both upper and lower
Guillaume Sicard <guitch21@gmail.com>
parents: 418
diff changeset
117 if(y>9 and y<36):
5ca2936f2062 Bug fix in per-class a priori error : should be lower than before for both upper and lower
Guillaume Sicard <guitch21@gmail.com>
parents: 418
diff changeset
118 predicted_class=numpy.argmax(out[0,10:36])+10
418
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
119 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
120 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
121
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
122 if(y<10):
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
123 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
124 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
125 total_error_count+=1
439
5ca2936f2062 Bug fix in per-class a priori error : should be lower than before for both upper and lower
Guillaume Sicard <guitch21@gmail.com>
parents: 418
diff changeset
126 if(y>35):
5ca2936f2062 Bug fix in per-class a priori error : should be lower than before for both upper and lower
Guillaume Sicard <guitch21@gmail.com>
parents: 418
diff changeset
127 predicted_class=numpy.argmax(out[0,36:])+36
418
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
128 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
129 total_error_count+=1
439
5ca2936f2062 Bug fix in per-class a priori error : should be lower than before for both upper and lower
Guillaume Sicard <guitch21@gmail.com>
parents: 418
diff changeset
130 #without a priori
5ca2936f2062 Bug fix in per-class a priori error : should be lower than before for both upper and lower
Guillaume Sicard <guitch21@gmail.com>
parents: 418
diff changeset
131 predicted_class=numpy.argmax(out)
5ca2936f2062 Bug fix in per-class a priori error : should be lower than before for both upper and lower
Guillaume Sicard <guitch21@gmail.com>
parents: 418
diff changeset
132 if(predicted_class!=y):
5ca2936f2062 Bug fix in per-class a priori error : should be lower than before for both upper and lower
Guillaume Sicard <guitch21@gmail.com>
parents: 418
diff changeset
133 total_error_count_wap+=1
5ca2936f2062 Bug fix in per-class a priori error : should be lower than before for both upper and lower
Guillaume Sicard <guitch21@gmail.com>
parents: 418
diff changeset
134
418
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
135 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
136 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
137 print '\t percentage of error: '+str(total_error_count*100.0/total_exemple_count*1.0)+' %'
439
5ca2936f2062 Bug fix in per-class a priori error : should be lower than before for both upper and lower
Guillaume Sicard <guitch21@gmail.com>
parents: 418
diff changeset
138 print '\t total error count without a priori: '+str(total_error_count_wap)
5ca2936f2062 Bug fix in per-class a priori error : should be lower than before for both upper and lower
Guillaume Sicard <guitch21@gmail.com>
parents: 418
diff changeset
139 print '\t percentage of error without a priori: '+str(total_error_count_wap*100.0/total_exemple_count*1.0)+' %'
418
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
140
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
141
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
142 def sigmoid(value):
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
143 ## 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
144 ## 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
145 ## 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
146 ## 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
147 ## return retour
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
148 ## else:
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
149 ## print len(value)
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
150 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
151
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
152 if __name__ == '__main__':
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 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
155
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
156 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
157 type = 0
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
158 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
159 type = 1
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
160
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
161 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
162
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
163 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
164
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
165 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
166 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
167 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
168 print "NIST DIGITS"
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
169 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
170 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
171 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
172 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
173 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
174 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
175 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
176
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
177
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
178 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
179 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
180 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
181 print "NIST DIGITS"
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
182 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
183 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
184 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
185 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
186 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
187 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
188 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
189
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
190
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
191 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
192 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
193 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
194 print "NIST DIGITS"
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
195 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
196 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
197 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
198 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
199 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
200 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
201 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
202
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
203 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
204 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
205 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
206 print "NIST DIGITS"
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
207 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
208 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
209 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
210 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
211 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
212 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
213 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
214
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
215 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
216 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
217 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
218 print "NIST DIGITS"
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
219 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
220 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
221 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
222 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
223 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
224 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
225 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
226
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
227 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
228 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
229 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
230 print "NIST DIGITS"
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
231 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
232 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
233 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
234 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
235 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
236 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
237 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
238
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
239
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
240
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
241
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
242
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
243
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
244
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
245
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
246
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
247
fb028b37ce92 Sert a calculer l'erreur sur les differentes classes de NIST.
SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
parents:
diff changeset
248