Access all weights of a model

You could flatten each parameter, append it in a list, and create a tensor:

model = models.resnet18()

params = []
for param in model.parameters():
    params.append(param.view(-1))
params = torch.cat(params)
print(params.shape)
> torch.Size([11689512])
2 Likes