Skip to content

RuntimeError: a view of a leaf Variable that requires grad is being used in an in-place operation. #4

@abhiagwl4262

Description

@abhiagwl4262

https://github.com/sovit-123/Traffic-Light-Detection-Using-YOLOv3/blob/master/models.py#L112-L116
There is an issue with this code which fails with torch=1.8.0

Code need to be updated as follows

            bias_ = module_list[j][0].bias.data  # shape(255,)
            bias = bias_[:modules.no * modules.na].view(modules.na, -1)  # shape(3,85)
            #bias[:, 4] += -4.5  # obj
            bias[:, 4] += math.log(8 / (640 / stride[yolo_index]) ** 2)  # obj (8 objects per 640 image)
            bias[:, 5:] += math.log(0.6 / (modules.nc - 0.99))  # cls (sigmoid(p) = 1/nc)
            module_list[j][0].bias = torch.nn.Parameter(bias, requires_grad=bias_.requires_grad)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions