I want to set the weight decay of the bias terms to zero and I am trying to do this using the named_parameter. The way I do it is through a function of the form
def setParams(network,state):
  
    params_dict = dict(network['model'].named_parameters())
    params=[]
  
    for key, value in params_dict.items():
        if key[-4:] == 'bias':
          
            params += [{'params':value,'weight_decay':0.0}]
  
    return params

and I call it inside the main as follows:
if __name__ == '__main__':

    #some other lines#
    #network list contains the optimizer,cost function and the model
    #state contains parameters required to define the network

    state['params']=setParams(network,state)

    network['optimizer'] =  torch.optim.SGD(state['params'],network['model'].parameters(), lr=state['learning rate'], momentum=state['momentum'],weight_decay=state['weight decay'],nesterov=True) #optimizer
    

But when I do this in pytorch 0.3 or 0.4 I get the error:
TypeError                                 Traceback (most recent call last)
<ipython-input-8-8ab30dfcadcd> in <module>()
    501     state['params']=setParams(network,state)
    502     network['cost criterion']=  torch.nn.CrossEntropyLoss() #cost function
--> 503     network['optimizer'] =  torch.optim.SGD(state['params'],network['model'].parameters(), lr=state['learning rate'], momentum=state['momentum'],weight_decay=state['weight decay'],nesterov=True) #optimizer
    504     #[{'params': resLayer4.bias, 'weight_decay': 0}, {'params': resLayer3.bias, 'weight_decay': 0}, {'params': resLayer2.bias, 'weight_decay': 0},   {'params': resLayer1.bias, 'weight_decay': 0}, {'params': batchNorm1.bias, 'weight_decay': 0},{'params': full1.bias, 'weight_decay': 0} ,{'params': batchNorm1.bias, 'weight_decay': 0} ]
    505 

TypeError: __init__() got multiple values for argument 'lr'