open-mmlab/mmdetection · warning
DeprecationWarning: Setting "linear=True" in IOULoss is depr
Error message
DeprecationWarning: Setting "linear=True" in IOULoss is deprecated, please use "mode=`linear`" instead.
What it means
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.
Source
Thrown at mmdet/models/losses/iou_loss.py:435
by mode. Default: False.
eps (float): Epsilon to avoid log(0).
reduction (str): Options are "none", "mean" and "sum".
loss_weight (float): Weight of loss.
mode (str): Loss scaling mode, including "linear", "square", and "log".
Default: 'log'
"""
def __init__(self,
linear: bool = False,
eps: float = 1e-6,
reduction: str = 'mean',
loss_weight: float = 1.0,
mode: str = 'log') -> None:
super().__init__()
assert mode in ['linear', 'square', 'log']
if linear:
mode = 'linear'
warnings.warn('DeprecationWarning: Setting "linear=True" in '
'IOULoss is deprecated, please use "mode=`linear`" '
'instead.')
self.mode = mode
self.linear = linear
self.eps = eps
self.reduction = reduction
self.loss_weight = loss_weight
def forward(self,
pred: Tensor,
target: Tensor,
weight: Optional[Tensor] = None,
avg_factor: Optional[int] = None,
reduction_override: Optional[str] = None,
**kwargs) -> Tensor:
"""Forward function.
Args:View on GitHub (pinned to cfd5d3a985)
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
Example fix
# before loss_iou=dict(type='IoULoss', linear=True, loss_weight=1.0) # after loss_iou=dict(type='IoULoss', mode='linear', loss_weight=1.0)
Defensive patterns
Strategy: validation
Validate before calling
assert 'linear' not in loss_iou_cfg, 'IoULoss: use mode=\'linear\' not linear=True'
Prevention
- Migrate loss configs together when bumping mmdet major versions
- Grep configs for legacy keys (linear=) in CI
When it happens
Trigger: Instantiating IoULoss(linear=True) directly or via config builder with a linear key present; old configs written before the mode parameter existed.
Common situations: Version upgrades of mmdet where loss configs were refactored; copied configs from older model zoos or tutorials.
Related errors
- DeprecationWarning: Setting "linear=True" in iou_loss is dep
- pretrained must be a str or None
- DeprecationWarning: pretrained is deprecated, please use "in
- DeprecationWarning: `num_anchors` is deprecated, for consist
- DeprecationWarning: anchor_generator is deprecated, please u
AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27).
Data as JSON: /api/errors/fd4c9ef8f6eb55df.
Report an issue: GitHub.