{"record":{"id":"fd4c9ef8f6eb55df","repo":"open-mmlab/mmdetection","slug":"deprecationwarning-setting-linear-true-in-ioulo","errorCode":null,"errorMessage":"DeprecationWarning: Setting \"linear=True\" in IOULoss is deprecated, please use \"mode=`linear`\" instead.","messagePattern":"DeprecationWarning: Setting \"linear=True\" in IOULoss is deprecated, please use \"mode=`linear`\" instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"mmdet/models/losses/iou_loss.py","lineNumber":435,"sourceCode":"            by mode. Default: False.\n        eps (float): Epsilon to avoid log(0).\n        reduction (str): Options are \"none\", \"mean\" and \"sum\".\n        loss_weight (float): Weight of loss.\n        mode (str): Loss scaling mode, including \"linear\", \"square\", and \"log\".\n            Default: 'log'\n    \"\"\"\n\n    def __init__(self,\n                 linear: bool = False,\n                 eps: float = 1e-6,\n                 reduction: str = 'mean',\n                 loss_weight: float = 1.0,\n                 mode: str = 'log') -> None:\n        super().__init__()\n        assert mode in ['linear', 'square', 'log']\n        if linear:\n            mode = 'linear'\n            warnings.warn('DeprecationWarning: Setting \"linear=True\" in '\n                          'IOULoss is deprecated, please use \"mode=`linear`\" '\n                          'instead.')\n        self.mode = mode\n        self.linear = linear\n        self.eps = eps\n        self.reduction = reduction\n        self.loss_weight = loss_weight\n\n    def forward(self,\n                pred: Tensor,\n                target: Tensor,\n                weight: Optional[Tensor] = None,\n                avg_factor: Optional[int] = None,\n                reduction_override: Optional[str] = None,\n                **kwargs) -> Tensor:\n        \"\"\"Forward function.\n\n        Args:","sourceCodeStart":417,"sourceCodeEnd":453,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/models/losses/iou_loss.py#L417-L453","documentation":"Deprecation warning from IoULoss.__init__: constructing IoULoss with the legacy `linear=True` argument is deprecated; use mode='linear' instead. The constructor asserts mode in ['linear','square','log'] and coerces mode when linear is set, warning before the flag is removed.","triggerScenarios":"Instantiating IoULoss(linear=True) directly or via config builder with a linear key present; old configs written before the mode parameter existed.","commonSituations":"Version upgrades of mmdet where loss configs were refactored; copied configs from older model zoos or tutorials.","solutions":["Change linear=True to mode='linear' in the IoULoss config","Delete the linear key if default 'log' mode is desired","Grep configs for 'linear=' and migrate"],"exampleFix":"# before\nloss_iou=dict(type='IoULoss', linear=True, loss_weight=1.0)\n# after\nloss_iou=dict(type='IoULoss', mode='linear', loss_weight=1.0)","handlingStrategy":"validation","validationCode":"assert 'linear' not in loss_iou_cfg, 'IoULoss: use mode=\\'linear\\' not linear=True'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Migrate loss configs together when bumping mmdet major versions","Grep configs for legacy keys (linear=) in CI"],"tags":["mmdet","deprecation","iou-loss","constructor"],"backgroundTag":"deprecated-argument-migrated","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}