you can use modules http://pytorch.org/docs/master/nn.html?highlight=named_parameters#torch.nn.Module.modules 275
param_group = []

for m in model.modules():
    if isinstance(m, nn.Linear):
        param_group.append(m.weight)
        if m.bias is not None:
            param_group.append(m.bias)