-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fine-tuning #30
Comments
Hi,
crnn = net.CRNN(params.imgH, params.nc, nclass, params.nh) here, the nclass should't equal to
crnn.rnn = nn.Sequential(
BidirectionalLSTM(512, nh, nh),
BidirectionalLSTM(nh, nh, nclass))
|
Thanks for the quick response. Thanks |
After load the model, change the rnn layer. |
Thank you Holmeyoung. Should I change crnn.py: |
Hi, you should change train.py to import torch.nn as nn
from models.crnn import BidirectionalLSTM
def net_init():
nclass_pre = 11 # the nclass of your pre-trained model: = len(params.alphabet--pre version) + 1
nclass = len(params.alphabet) + 1
crnn = net.CRNN(params.imgH, params.nc, nclass_pre, params.nh)
crnn.apply(weights_init)
if params.pretrained != '':
print('loading pretrained model from %s' % params.pretrained)
if params.multi_gpu:
crnn = torch.nn.DataParallel(crnn)
crnn.load_state_dict(torch.load(params.pretrained))
crnn.rnn = nn.Sequential(
BidirectionalLSTM(512, params.nh, params.nh),
BidirectionalLSTM(params.nh, params.nh, nclass))
return crnn |
Thank you very much. |
Hi Holmeyoung,
When I retrain a pre-trained model, it sounds like the model forgot what it has learned. I mean if I trained a model on synthetic images and fine-tuned the model with real-world images, the model accuracy on the synthetic images decreases. Please correct me if I am wrong, to use a pertained model, I should freeze the last layers. If so, how can I freeze the last layers?
Thanks
The text was updated successfully, but these errors were encountered: