Function or module to retrieve the attributes layer by layer for a neural network

Would like to know or find any function to retrieve the attributes such as stride, padding, dilation, groups, benchmark kind of values for each of the layer like convolution layer. Trying to kind of parse the model in pytorch. I could successfully read the values of weights, bais from each layer using function p = Model.parameters(), then using p.data_ptr().


You can directly access these parameters via:

conv = nn.Conv2d(
    kernel_size=(3, 4),
    stride=(5, 6),
    dilation=(7, 8),


Thank you for the reply, but im trying to traverse through each node of the model graph and came to a point of checking if the node is an operator. Now i want to copy all the inputs values(weights, bais, in_channels,kernel_size, etc) of each layer.

for (auto it = nodes.begin(); it != nodes.end(); ++it)

		std::cout << " " << std::endl;
		auto node = it->second->node();

		auto inp_size = it->second->node()->inputs();
		std::cout << "inp_sizeL:/n" << inp_size.size() << std::endl;
		if (it->second->node()->maybeOperator()) {
			//std::cout << *node.getparameters() << std::endl;```
So at this point, i would like to read all the inputs to each node. Is there any function like **getAttributes** or get_attributes("mods") to retrieve all the values. Thank you.