Hello,
I am trying to write a function which returns an optimizer from a dictionary, but I get the following error message:
ValueError: optimizer got an empty parameter list
The Function is as follows:
def pickOptimizer(opt, *args, **kwargs):
    optimizers = {
        'sgd': optim.SGD(*args, **kwargs),
        'asgd': optim.ASGD(*args, **kwargs),
        'adam': optim.Adam(*args, **kwargs),
        'adamw': optim.AdamW(*args, **kwargs),
        'adamax': optim.Adamax(*args, **kwargs),
        'rms': optim.RMSprop(*args, **kwargs),
        'rprop': optim.Rprop(*args, **kwargs),
        'adah': AdaHessian(*args, **kwargs)
    }
    return optimizers[opt]

If I write params=net.parameters() explicitly into the function it works as I expect otherwise I get an error. For this to work I need to put this function into my main document.
Thank you for any help.