--CODE--
...
self.step, self.epoch = 0, 0
self.valid_loss = float('inf')
self.valid_log = ['Start Time: {}'.format(self.start_time)]
self.ref_test_log = self.valid_log.copy()
self.asr_test_log = self.valid_log.copy()
# language model tokenizer
if self.config.lan_model:
self.tokenizer = AutoTokenizer.from_pretrained(self.config.lan_model)
if self.config.pos:
self.pos_tagger = SequenceTagger.load(self.config.pos) if self.config.pos else None
if self.config.use_pos:
self.config.tag_size = len(self.pos_tagger.tag_dictionary) if self.pos_tagger else None
if self.config.pretrained_pos_embed:
self.config.embedding_size = self.pos_tagger.linear.weight.shape[-1]
def load_data(self):
for file in [self.config.TRAIN_FILE, self.config.VALID_FILE
, self.config.REF_TEST_FILE, self.config.ASR_TEST_FILE]:
if not os.path.exists(self.config.DATA_JSON.format(file)):
raw_file = self.config.RAW_TXT.format(file)
raw_data = pipeline.read_file(raw_file, self.config)
raw_data = pipeline.parse_data(raw_data, self.tokenizer, self.config)
save.save_json(self.config.DATA_JSON.format(file), raw_data)
...
->I am using this part of code in train.py same as in your github repository, but I am getting error due to tag_dictionary attribute as
shown below
--ERROR--
(AttributeError: 'SequenceTagger' object has no attribute 'tag_dictionary')
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
PS C:\Users\Manikanth Shetty\OneDrive\Documents\POS-Tagger-for-Punctuation-Restoration-main> cd main
PS C:\Users\Manikanth Shetty\OneDrive\Documents\POS-Tagger-for-Punctuation-Restoration-main\main> python .\train.py
Initialize...
2022-06-07 18:26:15,095 loading file C:\Users\Manikanth Shetty.flair\models\upos-english-fast\b631371788604e95f27b6567fe7220e4a7e8d03201f3d862e6204dbf90f9f164.0afb95b43b32509bf4fcc3687f7c64157d8880d08f813124c1bd371c3d8ee3f7
2022-06-07 18:26:15,455 SequenceTagger predicts: Dictionary with 20 tags: , O, INTJ, PUNCT, VERB, PRON, NOUN, ADV, DET, ADJ, ADP, NUM, PROPN, CCONJ, PART, AUX, X, SYM, ,
Traceback (most recent call last):
File "C:\Users\Manikanth Shetty\OneDrive\Documents\POS-Tagger-for-Punctuation-Restoration-main\main\train.py", line 483, in
main()
File "C:\Users\Manikanth Shetty\OneDrive\Documents\POS-Tagger-for-Punctuation-Restoration-main\main\train.py", line 478, in main
re = Restorer()
File "C:\Users\Manikanth Shetty\OneDrive\Documents\POS-Tagger-for-Punctuation-Restoration-main\main\train.py", line 28, in init
self.initialize()
File "C:\Users\Manikanth Shetty\OneDrive\Documents\POS-Tagger-for-Punctuation-Restoration-main\main\train.py", line 57, in initialize
self.config.tag_size = len(self.pos_tagger.tag_dictionary) if self.pos_tagger else None
File "C:\Users\Manikanth Shetty\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\nn\modules\module.py", line 1185, in getattr
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'SequenceTagger' object has no attribute 'tag_dictionary'
PS C:\Users\Manikanth Shetty\OneDrive\Documents\POS-Tagger-for-Punctuation-Restoration-main\main>
-> please help me with this.