[BUG] KeyError when running the "Retrain a Model With New Tags" example
IsaacPushButton opened this issue · 3 comments
IsaacPushButton commented
Describe the bug
I copy pasted the "retrain a model with new tags" example and ran it, and I get the following exception:
Traceback (most recent call last):
File "example_retrain_tags.py", line 44, in <module>
logging_path=logging_path,
File "/home/ec2-user/deepparser_au_address/.venv/lib64/python3.7/site-packages/deepparse/parser/address_parser.py", line 719, in retrain
capturing_context=with_capturing_context,
File "/home/ec2-user/deepparser_au_address/.venv/lib64/python3.7/site-packages/deepparse/parser/address_parser.py", line 1085, in _retrain
disable_tensorboard=disable_tensorboard,
File "/home/ec2-user/deepparser_au_address/.venv/lib64/python3.7/site-packages/poutyne/framework/model_bundle.py", line 752, in train
return self._train(self.model.fit_generator, train_generator, valid_generator, **kwargs)
File "/home/ec2-user/deepparser_au_address/.venv/lib64/python3.7/site-packages/poutyne/framework/model_bundle.py", line 913, in _train
return training_func(*args, initial_epoch=initial_epoch, callbacks=expt_callbacks, **kwargs)
File "/home/ec2-user/deepparser_au_address/.venv/lib64/python3.7/site-packages/poutyne/framework/model.py", line 612, in fit_generator
self._fit_generator_one_batch_per_step(epoch_iterator, callback_list)
File "/home/ec2-user/deepparser_au_address/.venv/lib64/python3.7/site-packages/poutyne/framework/model.py", line 682, in _fit_generator_one_batch_per_step
for step, (x, y) in train_step_iterator:
File "/home/ec2-user/deepparser_au_address/.venv/lib64/python3.7/site-packages/poutyne/framework/iterators.py", line 89, in __iter__
for step, data in _get_step_iterator(self.steps_per_epoch, self.generator):
File "/home/ec2-user/deepparser_au_address/.venv/lib64/python3.7/site-packages/poutyne/framework/iterators.py", line 35, in cycle
for x in iterable:
File "/home/ec2-user/deepparser_au_address/.venv/lib64/python3.7/site-packages/torch/utils/data/dataloader.py", line 628, in __next__
data = self._next_data()
File "/home/ec2-user/deepparser_au_address/.venv/lib64/python3.7/site-packages/torch/utils/data/dataloader.py", line 1333, in _next_data
return self._process_data(data)
File "/home/ec2-user/deepparser_au_address/.venv/lib64/python3.7/site-packages/torch/utils/data/dataloader.py", line 1359, in _process_data
data.reraise()
File "/home/ec2-user/deepparser_au_address/.venv/lib64/python3.7/site-packages/torch/_utils.py", line 543, in reraise
raise exception
KeyError: Caught KeyError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/ec2-user/deepparser_au_address/.venv/lib64/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "/home/ec2-user/deepparser_au_address/.venv/lib64/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 61, in fetch
return self.collate_fn(data)
File "/home/ec2-user/deepparser_au_address/.venv/lib64/python3.7/site-packages/deepparse/converter/data_processor.py", line 82, in process_for_training
target_tmp = [self.tags_converter(target) for target in target_list]
File "/home/ec2-user/deepparser_au_address/.venv/lib64/python3.7/site-packages/deepparse/converter/data_processor.py", line 82, in <listcomp>
target_tmp = [self.tags_converter(target) for target in target_list]
File "/home/ec2-user/deepparser_au_address/.venv/lib64/python3.7/site-packages/deepparse/converter/target_converter.py", line 24, in __call__
return self.tags_to_idx[key]
KeyError: 'ATag'
To Reproduce
- Copy the script at https://github.com/GRAAL-Research/deepparse/blob/main/examples/retrain_with_new_prediction_tags.py into a python file
- Run it
Desktop (please complete the following information):
Im using deepparse 0.9.4 on amazon linux 2.
Additional context
Looks a lot like this closed issue related to another example script: #117
github-actions commented
Thank you for you interest in improving Deepparse.
davebulaval commented
Error is not the same. I found it. I'm currently working on a fix and adding tests to detect it next time. I will release a new version soon.
davebulaval commented
It is fixed in the new release version 0.9.5.