nlpyang / PreSumm

code for EMNLP 2019 paper Text Summarization with Pretrained Encoders
MIT License
1.29k stars 465 forks source link

Continue training from checkpoint issues #145

Open huydang90 opened 4 years ago

huydang90 commented 4 years ago

Hi, I am trying to load the checkpoint with -train_from ../models/model_step_15000.pt. However, the error "TypeError: 'Optimizer' object does not support indexing" keeps popping up. I have tried different fix but still haven't gotten around it. Would be great if you could point me in the right direction. Thank you!

[2020-04-03 04:47:29,780 INFO] loading weights file https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased-pytorch_model.bin from cache at ../temp/aa1ef1aede4482d0dbcd4d52baad8ae300e60902e88fcb0bebdec09afd232066.36ca03ab34a1a5d5fa7bc3d03d55c4fa650fed07220e2eeebc06ce58d0e9a157 Traceback (most recent call last): File "train.py", line 146, in train_ext(args, device_id) File "/content/drive/My Drive/News_Summarization_with_BERT/src/train_extractive.py", line 203, in train_ext train_single_ext(args, device_id) File "/content/drive/My Drive/News_Summarization_with_BERT/src/train_extractive.py", line 240, in train_single_ext optim = model_builder.build_optim(args, model, checkpoint) File "/content/drive/My Drive/News_Summarization_with_BERT/src/models/model_builder.py", line 16, in build_optim optim = checkpoint['optim'][0] TypeError: 'Optimizer' object does not support indexing

onrmrt commented 4 years ago

Hi, can you try accessing without index? optim = checkpoint ['optim'] instead of optim = checkpoint ['optim'][0]

siida36 commented 4 years ago

optim = checkpoint ['optim'] instead of optim = checkpoint ['optim'][0]

It works for me. Thanks!

connie-n commented 2 years ago

I tried above solution but it didn't work.. could anyone help?

File "/content/drive/MyDrive/Colab/github/PreSumm/src/models/model_builder.py", line 16, in build_optim optim = checkpoint['optim'] KeyError: 'optim'

Rumi4 commented 2 years ago

Hi! Just type 'optims' in checkpoint['optim'] it works.

WSChange commented 8 months ago

I tried above solution but it didn't work.. could anyone help?

File "/content/drive/MyDrive/Colab/github/PreSumm/src/models/model_builder.py", line 16, in build_optim optim = checkpoint['optim'] KeyError: 'optim'

Hi, did you solve this problem?