sairin1202 / Commonsense-Knowledge-Aware-Concept-Selection-For-Diverse-and-Informative-Visual-Storytelling

The implement of Commonsense Knowledge Aware Concept Selection For Diverse and Informative Visual Storytelling
MIT License
11 stars 2 forks source link

RuntimeError: cannot train after make_generation_fast #3

Open caoyuanbao opened 3 years ago

caoyuanbao commented 3 years ago

When I run the train.py in visualstorytelling, errors happens as list, do you have the solution?:

Traceback (most recent call last):
  File "train.py", line 109, in <module>
    main()
  File "train.py", line 105, in main
    train_model(opt, bart, dataset, test_dataset, 10)
  File "train.py", line 42, in train_model
    bart._model.train()
  File "/home/caidesheng/miniconda3/envs/teran/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1277, in train
    module.train(mode)
  File "/home/caidesheng/miniconda3/envs/teran/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1277, in train
    module.train(mode)
  File "/home/caidesheng/miniconda3/envs/teran/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1277, in train
    module.train(mode)
  File "/home/caidesheng/.cache/torch/hub/pytorch_fairseq_master/fairseq/models/fairseq_model.py", line 212, in train
    raise RuntimeError("cannot train after make_generation_fast")
RuntimeError: cannot train after make_generation_fast

it seems due to the code in fairseq_model.py of fairseq:

apply_make_generation_fast_(self, "")
def train(mode=True):
   if mode:
        raise RuntimeError("cannot train after make_generation_fast")

# this model should no longer be used for training
self.eval()
self.train = train
sairin1202 commented 3 years ago

seems the fairseq I used is out-dated, I will turn this into huggingface as soon as possible