Skip to content

KeyError: unlabeled_train_iter.next() #29

Open

Description

@SSSXHJDB

%run /code/train.py --gpu=0 --n-labeled=10 --data-path /yahoo_answers_csv/ --batch-size=4 --batch-size-u=8 --epochs=50 --val-iteration=20 --lambda-u=0 --T=0.5 --alpha=16 --mix-layers-set 7 9 12 --separate-mix=True

train(labeled_trainloader, unlabeled_trainloader, model, optimizer, scheduler, criterion, epoch, n_labels, train_aug)
204 (inputs_u, inputs_u2, inputs_ori), (length_u,
--> 205 length_u2, length_ori) = unlabeled_train_iter.next()
206 except:

/torch/utils/data/dataloader.py in next(self)
520 self._reset()
--> 521 data = self._next_data()
522 self._num_yielded += 1

/torch/utils/data/dataloader.py in _next_data(self)
560 index = self._next_index() # may raise StopIteration
--> 561 data = self._dataset_fetcher.fetch(index) # may raise StopIteration
562 if self._pin_memory:

/torch/utils/data/_utils/fetch.py in fetch(self, possibly_batched_index)
43 if self.auto_collation:
---> 44 data = [self.dataset[idx] for idx in possibly_batched_index]
45 else:

/torch/utils/data/_utils/fetch.py in (.0)
43 if self.auto_collation:
---> 44 data = [self.dataset[idx] for idx in possibly_batched_index]
45 else:

/code/read_data.py in getitem(self, idx)
209 if self.aug is not None:
--> 210 u, v, ori = self.aug(self.text[idx], self.ids[idx])
211 encode_result_u, length_u = self.get_tokenized(u)

/code/read_data.py in call(self, ori, idx)
22 def call(self, ori, idx):
---> 23 out1 = self.de[idx]
24 out2 = self.ru[idx]

KeyError: 9226

May I ask what is the reason for this place? Thank you very much.

Activity

  1. LauJames commented on Jun 1, 2022

    @LauJames

    I have met the same issue...

  2. kehanguo commented on Aug 9, 2022

    @kehanguo

    I have the same issue. Did anyone solve it yet?

  3. jiaaoc commented on Sep 21, 2022

    @jiaaoc
    Member

    This might be related to the dictionary file about the back-translations. This might be because several sentences are not back-translated, like the 9226th sentence.

  4. 2514099958 commented on Feb 14, 2023

    @2514099958

    Has anyone already downloaded the preprocessed dataset? The original URL is invalid, can anyone share the preprocessed dataset? Many thanks.

  5. kocemir commented on Aug 7, 2025

    @kocemir

    It requieres the translation files. If you cannot use translator, you can do the following: In read_data.py,

    train_unlabeled_dataset = loader_unlabeled(
        train_text[train_unlabeled_idxs], train_unlabeled_idxs, tokenizer, max_seq_len, **None**)
    

    In the original repo, None is Translator(path). After doing that, you should modify a lot of lines in training. py file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions