Hello! I am trying to train a convolutional neural network. I’ve created the network structure, and am instantiating an object of the network class. However, I am unable to access the parameters of the model, and I’m wondering if there’s something silly I’ve forgotten. I’m not the most comfortable with c++, so it’s possible I’ve made some ownership mistake or something. This also leads to the wealth of information accessible in the docs overloading my brain a little bit. Anyway, here is my network architecture, located in a header file:
class ConvNet : torch::nn::Module {
	public:
		ConvNet(){
			register_module("layer1", layer1);
			register_module("layer2", layer2);
			register_module("fc", fc);
		};
		torch::Tensor forward(torch::Tensor x){
			x = layer1->forward(x);
			x = layer2->forward(x);
			x = x.view({-1, x.size(1) * x.size(2) * x.size(3)});
			x = fc->forward(x);
			return x;
		};

	private:
		torch::nn::Sequential layer1{
			torch::nn::Conv2d(torch::nn::Conv2dOptions(3, 64, 3).stride(1).padding(1)),
			torch::nn::ReLU(),
			torch::nn::MaxPool2d(torch::nn::MaxPool2dOptions({2, 2}).stride(2))
			};

		torch::nn::Sequential layer2{
			torch::nn::Conv2d(torch::nn::Conv2dOptions(64, 64, 3).stride(1).padding(1)),
			torch::nn::ReLU(),
			torch::nn::MaxPool2d(torch::nn::MaxPool2dOptions({2, 2}).stride(2))
			};

		torch::nn::Sequential fc{
			torch::nn::Linear(torch::nn::LinearOptions(64 * 50 * 125, 64)),
			torch::nn::ReLU(),
			torch::nn::Linear(torch::nn::LinearOptions(64, 1)),
			torch::nn::Sigmoid()
			};
			
};


And here, in my implementation file is where I’m trying to view the parameters:
ConvNet cnn;
cout << cnn.parameters();

This is leading to the errors:
std::vectorat::Tensor torch::nn::Module::parameters(bool) const’ is inaccessible within this context
58 |  cout << cnn.parameters() << endl;
and
‘torch::nn::Module’ is not an accessible base of ‘ConvNet’
58 |  cout << cnn.parameters() << endl;
Any guidance would be much appreciated. Thank you!