I’m trying to display the optimizer currently in use by the model for documentation purposes.
So the following snippet
optimizer = torch.optim.SGD(model.parameters(), lr=1e-5)
print(optimizer)
gives the following output
SGD (
Parameter Group 0
dampening: 0
lr: 1e-05
momentum: 0
nesterov: False
weight_decay: 0
)
Is there a way in which I could just get SGD
as the output (and same for other optimizers also)?
I figured I could take the substring of the displayed output till the first parenthesis. Is there a cleaner way of doing this?