Skip to content
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

pretrained model for fine-tuning #267

Open
kimlia545 opened this issue Feb 3, 2021 · 0 comments
Open

pretrained model for fine-tuning #267

kimlia545 opened this issue Feb 3, 2021 · 0 comments

Comments

@kimlia545
Copy link

kimlia545 commented Feb 3, 2021

I added more character('train.py' --character) and got an error (size mismatch)
I don't know why It works when the Prediction is different from what pretrained model's Prediction
for example these code is work

python train.py --train_data data_lmdb/training --workers 0 --valid_data data_lmdb/validation --Transformation TPS --FeatureExtraction ResNet --SequenceModeling BiLSTM --Prediction CTC --saved_model pretrained_models/TPS-ResNet-BiLSTM-Attn.pth --FT

python train.py --train_data data_lmdb/training --workers 0 --valid_data data_lmdb/validation --Transformation TPS --FeatureExtraction ResNet --SequenceModeling BiLSTM --Prediction Attn --saved_model pretrained_models/TPS-ResNet-BiLSTM-CTC.pth --FT

but If Prediction is the same as pretrained_model has

python train_test.py --train_data data_lmdb/training --workers 0 --valid_data data_lmdb/validation --Transformation TPS --FeatureExtraction ResNet --SequenceModeling BiLSTM --Prediction Attn --saved_model pretrained_models/TPS-ResNet-BiLSTM-Attn.pth --FT

RuntimeError: Error(s) in loading state_dict for DataParallel:
size mismatch for module.Prediction.attention_cell.rnn.weight_ih: copying a param with shape torch.Size([1024, 294]) from checkpoint, the shape in current model is torch.Size([1024, 1637]).
size mismatch for module.Prediction.generator.weight: copying a param with shape torch.Size([38, 256]) from checkpoint, the shape in current model is torch.Size([1381, 256]).
size mismatch for module.Prediction.generator.bias: copying a param with shape torch.Size([38]) from checkpoint, the shape in current model is torch.Size([1381]).

and How to fix this error
'demo.py'
confidence_score = pred_max_prob.cumprod(dim=0)[-1]
IndexError: index -1 is out of bounds for dimension 0 with size 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant