MCPcopy Create free account
hub / github.com/twitter/the-algorithm-ml / update

Method update

metrics/rce.py:152–167  ·  view source on GitHub ↗

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
  )

Source from the content-addressed store, hash-verified

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 """

Callers 5

forwardMethod · 0.95
forwardMethod · 0.45
updateMethod · 0.45
create_metricsFunction · 0.45
forwardMethod · 0.45

Calls 1

_smoothFunction · 0.85

Tested by

no test coverage detected