Mmdetection: How to use the custom optimizer?

Created on 1 Feb 2020  路  4Comments  路  Source: open-mmlab/mmdetection

I want to customize the optimizer(RAdam etc.), but I find that the optimizer in mmdetection is imported from torch.optim(only a few of optimizer are implemented), can you provide an official example to do this? Thank you

Most helpful comment

I figured out using this way:

from mmcv.runner.optimizer import build_optimizer, OPTIMIZERS
from my_optimizer import MyOptimizer
OPTIMIZERS.register_module()(MyOptimizer)

optim_cfg = dict(type="MyOptimizer", lr=0.001)
optimizer = build_optimizer(model, optim_cfg)

All 4 comments

We will introduce an optimizer registry like dataset or model registry to support customizing the optimizer. As a walkaround now, you may just modify this line and get your own optimizer class.

OK, I'll try, thanks

It seems the custom optimizer documentation is out of date. How to use custom optimizer after the cleaning of optimizer code?

I figured out using this way:

from mmcv.runner.optimizer import build_optimizer, OPTIMIZERS
from my_optimizer import MyOptimizer
OPTIMIZERS.register_module()(MyOptimizer)

optim_cfg = dict(type="MyOptimizer", lr=0.001)
optimizer = build_optimizer(model, optim_cfg)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

fmassa picture fmassa  路  3Comments

fatLime picture fatLime  路  3Comments

tianxinhang picture tianxinhang  路  3Comments

michaelisc picture michaelisc  路  3Comments

songyuc picture songyuc  路  3Comments