diff baseline/mlp/mlp_get_error_from_model.py @ 237:9b6e0af062af

corrected a bug in jobman interface
author xaviermuller
date Mon, 15 Mar 2010 10:09:50 -0400
parents e390b0454515
children
line wrap: on
line diff
--- a/baseline/mlp/mlp_get_error_from_model.py	Mon Mar 15 09:22:52 2010 -0400
+++ b/baseline/mlp/mlp_get_error_from_model.py	Mon Mar 15 10:09:50 2010 -0400
@@ -8,8 +8,8 @@
 from pylearn.io import filetensor as ft
 
 data_path = '/data/lisa/data/nist/by_class/'
-test_data = 'all/all_test_data.ft'
-test_labels = 'all/all_test_labels.ft'
+test_data = 'all/all_train_data.ft'
+test_labels = 'all/all_train_labels.ft'
 
 def read_test_data(mlp_model):
     
@@ -40,7 +40,7 @@
     b1=everything[1]
     W2=everything[2]
     b2=everything[3]
-    test_data=everything[4]/255.0
+    test_data=everything[4]
     test_labels=everything[5]
     total_error_count=0
     total_exemple_count=0
@@ -60,7 +60,7 @@
     for i in range(test_labels.size):
         total_exemple_count = total_exemple_count +1
         #get activation for layer 1
-        a0=np.dot(np.transpose(W1),np.transpose(test_data[i])) + b1
+        a0=np.dot(np.transpose(W1),np.transpose(test_data[i]/255.0)) + b1
         #add non linear function to layer 1 activation
         a0_out=np.tanh(a0)
         
@@ -78,17 +78,44 @@
             total_error_count = total_error_count +1
             
         #get grouped based error
+	#with a priori
+#        if(wanted_class>9 and wanted_class<35):
+#            min_exemple_count=min_exemple_count+1
+#            predicted_class=np.argmax(a1_out[10:35])+10
+#            if(predicted_class!=wanted_class):
+#		min_error_count=min_error_count+1
+#        if(wanted_class<10):
+#           nb_exemple_count=nb_exemple_count+1
+#            predicted_class=np.argmax(a1_out[0:10])
+#            if(predicted_class!=wanted_class):
+#                nb_error_count=nb_error_count+1
+#        if(wanted_class>34):
+#            maj_exemple_count=maj_exemple_count+1
+#            predicted_class=np.argmax(a1_out[35:])+35
+#            if(predicted_class!=wanted_class):
+#                maj_error_count=maj_error_count+1
+#                
+#        if(wanted_class>9):
+#            char_exemple_count=char_exemple_count+1
+#            predicted_class=np.argmax(a1_out[10:])+10
+#            if(predicted_class!=wanted_class):
+#                char_error_count=char_error_count+1
+		
+		
+		
+	#get grouped based error
+	#with no a priori
         if(wanted_class>9 and wanted_class<35):
             min_exemple_count=min_exemple_count+1
             predicted_class=np.argmax(a1_out)
             if(predicted_class!=wanted_class):
 		min_error_count=min_error_count+1
-        elif(wanted_class<10):
+        if(wanted_class<10):
             nb_exemple_count=nb_exemple_count+1
             predicted_class=np.argmax(a1_out)
             if(predicted_class!=wanted_class):
                 nb_error_count=nb_error_count+1
-        elif(wanted_class>34):
+        if(wanted_class>34):
             maj_exemple_count=maj_exemple_count+1
             predicted_class=np.argmax(a1_out)
             if(predicted_class!=wanted_class):