Skip to content
Advertisement

using ModuleList, still getting ValueError: optimizer got an empty parameter list

With Pytorch I am attempting to use ModuleList to ensure model parameters are detected, and can be optimized. When calling the SGD optimizer I get the following error:

ValueError: optimizer got an empty parameter list

Can you please review the code below and advise?

JavaScript

Advertisement

Answer

This seems to be a copy-paste issue: your __init__ has 3 underscores instead of 2, both at __init__(self) and super(LR, self).__init__(). Thus the init itself failed. Delete the extra underscores and try again or try the below code:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement