Ejemplo n.º 1
0
 def accumulate_error(self):
     if self.config['error_evaluation'] == 'classification':
         predicted_labels = gpu.argmax(self.root.out) 
         target_labels = gpu.argmax(self.root.target)
         gpu.equal(predicted_labels, target_labels, target_labels)
         #print target_labels.sum(), target_labels.shape_tensor
         
         error = 1.0-(target_labels.sum()/self.out.shape[2])
       
     elif self.config['error_evaluation'] == 'logloss':
         size =  self.root.out.shape_tensor[2]
         error = (self.root.target*gpu.log(self.root.out+1e-15)).sum()/np.float32(-size)
     elif self.config['error_evaluation'] == 'regression':
         error = gpu.sum((self.activation-self.root.out)**2)/np.float32(self.root.out.shape_tensor[2]*self.root.out.shape_tensor[3])
         
     self.current_error.append(error) 
     self.current_SE.append(np.array(self.current_error).std()/len(self.current_error))        
Ejemplo n.º 2
0
 def predict(self, data):
     self.forward(data, None,False)   
     if type(self.root.funcs) == Softmax:            
         if self.config['error_evaluation'] == 'classification':
             return gpu.argmax(self.root.out)              
         elif self.config['error_evaluation'] == 'logloss':
             return self.root.out
     else: return self.root.out 
Ejemplo n.º 3
0
 def predict(self, data):
     self.forward(data, None, False)
     if type(self.root.funcs) == Softmax:
         if self.config['error_evaluation'] == 'classification':
             return gpu.argmax(self.root.out)
         elif self.config['error_evaluation'] == 'logloss':
             return self.root.out
     else:
         return self.root.out
Ejemplo n.º 4
0
    def accumulate_error(self):
        if self.config['error_evaluation'] == 'classification':
            predicted_labels = gpu.argmax(self.root.out)
            target_labels = gpu.argmax(self.root.target)
            gpu.equal(predicted_labels, target_labels, target_labels)
            #print target_labels.sum(), target_labels.shape_tensor

            error = 1.0 - (target_labels.sum() / self.out.shape[2])

        elif self.config['error_evaluation'] == 'logloss':
            size = self.root.out.shape_tensor[2]
            error = (self.root.target *
                     gpu.log(self.root.out + 1e-15)).sum() / np.float32(-size)
        elif self.config['error_evaluation'] == 'regression':
            error = gpu.sum((self.activation - self.root.out)**2) / np.float32(
                self.root.out.shape_tensor[2] * self.root.out.shape_tensor[3])

        self.current_error.append(error)
        self.current_SE.append(
            np.array(self.current_error).std() / len(self.current_error))