MCPcopy Create free account
hub / github.com/TPCD/DCCL / update

Method update

project_utils/general_utils.py:227–251  ·  view source on GitHub ↗
(self, preds, labels=None)

Source from the content-addressed store, hash-verified

225 self.running_start_idx = 0
226
227 def update(self, preds, labels=None):
228
229 # Expect preds in shape B x C
230
231 if torch.is_tensor(preds):
232 preds = preds.detach().cpu().numpy()
233
234 b, c = preds.shape
235
236 if self.all_preds is None:
237 self.all_preds = np.zeros((self.length, c))
238
239 self.all_preds[self.running_start_idx: self.running_start_idx + b] = preds
240
241 if labels is not None:
242 if torch.is_tensor(labels):
243 labels = labels.detach().cpu().numpy()
244
245 if self.all_labels is None:
246 self.all_labels = np.zeros((self.length,))
247
248 self.all_labels[self.running_start_idx: self.running_start_idx + b] = labels
249
250 # Maintain running index on dataset being evaluated
251 self.running_start_idx += b
252
253 def save(self):
254

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected