MCPcopy Index your code
hub / github.com/tinygrad/tinygrad / encode

Method encode

examples/mlperf/helpers.py:317–336  ·  view source on GitHub ↗
(self, reference_boxes, proposals)

Source from the content-addressed store, hash-verified

315 self.apply_to_remove = apply_to_remove
316
317 def encode(self, reference_boxes, proposals):
318 TO_REMOVE = self.apply_to_remove # TODO remove
319 ex_widths = proposals[..., 2] - proposals[..., 0] + TO_REMOVE
320 ex_heights = proposals[..., 3] - proposals[..., 1] + TO_REMOVE
321 ex_ctr_x = proposals[..., 0] + 0.5 * ex_widths
322 ex_ctr_y = proposals[..., 1] + 0.5 * ex_heights
323
324 gt_widths = reference_boxes[..., 2] - reference_boxes[..., 0] + TO_REMOVE
325 gt_heights = reference_boxes[..., 3] - reference_boxes[..., 1] + TO_REMOVE
326 gt_ctr_x = reference_boxes[..., 0] + 0.5 * gt_widths
327 gt_ctr_y = reference_boxes[..., 1] + 0.5 * gt_heights
328
329 wx, wy, ww, wh = self.weights
330 targets_dx = wx * (gt_ctr_x - ex_ctr_x) / ex_widths
331 targets_dy = wy * (gt_ctr_y - ex_ctr_y) / ex_heights
332 targets_dw = ww * Tensor.log(gt_widths / ex_widths)
333 targets_dh = wh * Tensor.log(gt_heights / ex_heights)
334
335 targets = Tensor.stack(targets_dx, targets_dy, targets_dw, targets_dh, dim=-1)
336 return targets
337
338 def decode(self, rel_codes, boxes):
339 boxes = boxes.cast(rel_codes.dtype)

Callers 10

train_gpt2.pyFile · 0.45
train_stable_diffusionFunction · 0.45
__init__Method · 0.45
__init__Method · 0.45
initFunction · 0.45
encodeFunction · 0.45
encodeRoleFunction · 0.45
encodeMessageFunction · 0.45
prepare_browser_chunksFunction · 0.45
validate_modelFunction · 0.45

Calls 2

logMethod · 0.80
stackMethod · 0.80

Tested by

no test coverage detected