jerryzh168:

what is torch::nn::Linear ? are you talking about the pytorch c++ API? the weights are packed in linear modules, you can use https://github.com/pytorch/pytorch/blob/master/torch/nn/quantized/modules/linear.py#L34  to get the unpacked weights.


Yes, I mean C++ API. As mentioned in description, I have trained the model in Python and exported it as torchscript to C++. Is the function “_weight_bias” accessible in torchscript format () (I can see that it is has the decorator @torch.jit.export) ? If yes, can you show please how to use it with loaded torchscript models ?
Rephrase 3-: Given a model that is trained in python, saved as “torchscript”  and loaded into C++ front end, I want to extract the number of layers, the type of each layer (Linear,conv1d…), the size of each layer and weights associated with each layer… How can I do that ?