I’m trying to use a modulelist to inside a module to create a multi-layer perceptron where the user can specify the number and size of hidden elements. Signature of constructor is:
MLPImpl(int64_t inputdim, int64_t outputdim, std::vector<int64_t> hidden)
MLPImpl has member variable
torch::nn::ModuleList layers;

I call register_module(“layers”, layers)  in constructor, and add some linear layers to the “layers” member via push_Back. Looking at implementation, this should also register those layers, so I don’t separately register those.
But somehow, this won’t work when I use torch::save and torch::load to store the neural network. I.e. the linear submodules contained “layers” won’t load.
Am I missing something here?