(matched, priors, variances)
return torch.cat([g_cxcy, g_wh], 1)
Encode the variances from the priorbox layers into the ground truth boxes
    we have matched (based on jaccard overlap) with the prior boxes.
    Args:
        matched: (tensor) Coords of ground truth for each prior in point-form
            Shape: [num_priors, 4].
        priors: (tensor) Prior boxes in center-offset form
            Shape: [num_priors,4].
        variances: (list[float]) Variances of priorboxes
    Return:
        encoded boxes (tensor), Shape: [num_priors, 4]
Encode the variances from the priorbox layers into the ground truth boxes
    we have matched (based on jaccard overlap) with the prior boxes.
    Args:
        matched: (tensor) Coords of ground truth for each prior in point-form
            Shape: [num_priors, 4].
        priors: (tensor) Prior boxes in center-offset form
            Shape: [num_priors,4].
        variances: (list[float]) Variances of priorboxes
    Return:
        encoded boxes (tensor), Shape: [num_priors, 4]
Encode the variances from the priorbox layers into the ground truth boxes we have matched ( based on jaccard overlap ) with the prior boxes . Args : matched : ( tensor ) Coords of ground truth for each prior in point - form Shape : [ num_priors 4 ] . priors : ( tensor ) Prior boxes in center - offset form Shape : [ num_priors 4 ] . variances : ( list [ float ] ) Variances of priorboxes Return : encoded boxes ( tensor ) Shape : [ num_priors 4 ]
def encode(matched, priors, variances):
    """Encode the variances from the priorbox layers into the ground truth boxes
    we have matched (based on jaccard overlap) with the prior boxes.
    Args:
        matched: (tensor) Coords of ground truth for each prior in point-form
            Shape: [num_priors, 4].
        priors: (tensor) Prior boxes in center-offset form
            Shape: [num_priors,4].
        variances: (list[float]) Variances of priorboxes
    Return:
        encoded boxes (tensor), Shape: [num_priors, 4]
    """

    # dist b/t match center and prior's center
    g_cxcy = (matched[:, :2] + matched[:, 2:]) / 2 - priors[:, :2]
    # encode variance
    g_cxcy /= (variances[0] * priors[:, 2:])
    # match wh / prior wh
    g_wh = (matched[:, 2:] - matched[:, :2]) / priors[:, 2:]
    g_wh = torch.log(g_wh) / variances[1]
    # return target for smooth_l1_loss
    return torch.cat([g_cxcy, g_wh], 1)
def encode ( matched , priors , variances ) : # dist b/t match center and prior's center g_cxcy = ( matched [ : , : 2 ] + matched [ : , 2 : ] ) / 2 - priors [ : , : 2 ] # encode variance g_cxcy /= ( variances [ 0 ] * priors [ : , 2 : ] ) # match wh / prior wh g_wh = ( matched [ : , 2 : ] - matched [ : , : 2 ] ) / priors [ : , 2 : ] g_wh = torch . log ( g_wh ) / variances [ 1 ] # return target for smooth_l1_loss return torch . cat ( [ g_cxcy , g_wh ] , 1 )