I tried mimicking LambdaLR : https://pytorch.org/docs/stable/_modules/torch/optim/lr_scheduler.html#LambdaLR 19
I now moved super(Cyc_lr, self).__init__(optimizer, last_epoch) to the bottom of the init block am now getting :


<ipython-input-136-f82e03f14fb9> in __init__(self, optimizer, lr_max, lr_min, datasize, bs, epochs, last_epoch)
     47 
     48         self.maxn=len(self.y)-1   # length of cos list
---> 49         super(Cyc_lr, self).__init__(optimizer, last_epoch)
     50     def get_lr(self):
     51         if 'self.max_lr' not in locals(): self.max_lr=0.1

/Users/admin/anaconda2/lib/python2.7/site-packages/torch/optim/lr_scheduler.pyc in __init__(self, optimizer, last_epoch)
     22                                    "in param_groups[{}] when resuming an optimizer".format(i))
     23         self.base_lrs = list(map(lambda group: group['initial_lr'], optimizer.param_groups))
---> 24         self.step(last_epoch + 1)
     25         self.last_epoch = last_epoch
     26 

/Users/admin/anaconda2/lib/python2.7/site-packages/torch/optim/lr_scheduler.pyc in step(self, epoch)
     49             epoch = self.last_epoch + 1
     50         self.last_epoch = epoch
---> 51         for param_group, lr in zip(self.optimizer.param_groups, self.get_lr()):
     52             param_group['lr'] = lr
     53 

TypeError: zip argument #2 must support iteration

instead of no attribute 'max_lr' as before while no attribute 'optimizer' persists