Update the current rce. Args: predictions: Predicted values. target: Ground truth. Should have same shape as predictions. weight: The weight to use for the predicted values. Shape should be broadcastable to that of predictions.
(
self, predictions: torch.Tensor, target: torch.Tensor, weight: float = 1.0
)
| 150 | self.batch_metric = copy.deepcopy(self) |
| 151 | |
| 152 | def update( |
| 153 | self, predictions: torch.Tensor, target: torch.Tensor, weight: float = 1.0 |
| 154 | ) -> torch.Tensor: |
| 155 | """ |
| 156 | Update the current rce. |
| 157 | Args: |
| 158 | predictions: Predicted values. |
| 159 | target: Ground truth. Should have same shape as predictions. |
| 160 | weight: The weight to use for the predicted values. Shape should be broadcastable to that of |
| 161 | predictions. |
| 162 | """ |
| 163 | target = _smooth(target, self.label_smoothing) |
| 164 | self.mean_label.update(target, weight) |
| 165 | self.binary_cross_entropy.update( |
| 166 | self.bce_loss_fn(predictions, target, reduction="none"), weight |
| 167 | ) |
| 168 | |
| 169 | def compute(self) -> torch.Tensor: |
| 170 | """ |