I want to do this since I need two optimizers to take care of different model parameters.

for example, my model has many layers and an architecture parameter model.arch:

```
class model(nn.Module):
def __init__(self):
...
self.linear_layers = nn.ModuleList()
for i in range(4):
self.linear_layers.append(nn.Linear(...))
# many other layers
self.arch = torch.zeros([...], requires_grad=True)
def get_arch_parameters(self):
return [self.arch]
def get_other_parameters(self):
# I want to return all parameters other than self.arch
```

Now I want to use two optimizers to update different parameters:

```
opt1 = torch.optim.SGD(model.get_other_parameters(), ...)
opt2 = torch.optim.SGD(model.get_arch_parameters(), ...)
```

However, I do not know how to implement model.get_other_parameters(), which returns all model parameters but model.arch.

I cannot simply set model.arch.requries_grad=False and use model.parameters() instead, since opt2 needs to update it.

Hence I’d like to know if there is any method to exclude a parameter from model.parameters() without setting its requires_grad to False.

Thanks in advance.