pytorch/lr_scheduler.py at master · pytorch/pytorch · GitHub 1 shows that the TypeError will be raised when your customized optimizer is not an instance Optimizer.
Does your customized optimizer subclass the base class Optimizer?