GabrielDornelles / pytorch-ocr

Simple Pytorch framework to train OCRs. Supports CRNNs, Attention, CTC and Cross Entropy Loss.
MIT License
70 stars 16 forks source link

How can I change weight decay? #2

Closed Xzoky174 closed 1 year ago

Xzoky174 commented 1 year ago

Hello! I'm new to ML and PyTorch. For a project, I need to adjust the weight decay for the ocr and compare results. How can I do that?

Thank you!

GabrielDornelles commented 1 year ago

In Pytorch weight decay (L2 Regularization) is applied in the optimizer. You can change it here to:

optimizer = torch.optim.Adam(model.parameters(), lr=cfg.training.lr, weight_decay=0.001)

Its not applied currently in the project because I don't think it would change the results, but I would be happy to know the results you achieved.