Exemplo n.º 1
0
 def update(self, input, target):
     self.y_true = tensor_to_numpy(target)
     if self.normalizate and self.task_type == 'binary':
         y_prob = tensor_to_numpy(input.sigmoid().data)
     elif self.normalizate and self.task_type == 'multiclass':
         y_prob = tensor_to_numpy(input.softmax(-1).data)
     else:
         y_prob = tensor_to_numpy(input)
     if self.task_type == 'binary':
         if self.thresh and self.search_thresh == False:
             self.y_pred = (y_prob > self.thresh).astype(int)
             self.value()
         else:
             thresh, f1 = self.thresh_search(y_prob=y_prob)
             print(f"Best thresh: {thresh:.4f} - F1 Score: {f1:.4f}")
     if self.task_type == 'multiclass':
         self.y_pred = np.argmax(y_prob, 1)
Exemplo n.º 2
0
 def update(self, input, target):
     if self.task_type == 'binary':
         self.y_prob = tensor_to_numpy(input.sigmoid().data)
     else:
         self.y_prob = tensor_to_numpy(input.softmax(-1).data)
     self.y_true = tensor_to_numpy(target)
Exemplo n.º 3
0
 def value(self):
     return matthews_corrcoef(tensor_to_numpy(self.labels),
                              tensor_to_numpy(self.preds))
Exemplo n.º 4
0
 def update(self, input, target):
     self.y_prob = tensor_to_numpy(input.sigmoid().data)
     self.y_true = tensor_to_numpy(target)
Exemplo n.º 5
0
 def update(self, input, target):
     _, y_pred = torch.max(input, 1)
     self.y_pred = tensor_to_numpy(y_pred)
     self.y_true = tensor_to_numpy(target)