You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
I have a highly imbalanced dataset, where some minority classes are very rare. I put them ONLY into the validation set. I want to validate, if the model can classify them not to be in the majority class.
However my training crashes at the beginning with Validation sanity check:. Tracelog:
KeyError: Caught KeyError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
data = fetcher.fetch(index)
File "/usr/local/lib/python3.8/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/usr/local/lib/python3.8/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/usr/local/lib/python3.8/dist-packages/flash/core/data/io/input.py", line 317, in __getitem__
return self._call_load_sample(self.data[index])
File "/usr/local/lib/python3.8/dist-packages/flash/core/data/io/input.py", line 236, in _call_load_sample
return load_sample(copy(sample))
File "/usr/local/lib/python3.8/dist-packages/flash/image/classification/input.py", line 49, in load_sample
sample[DataKeys.TARGET] = self.format_target(sample[DataKeys.TARGET])
File "/usr/local/lib/python3.8/dist-packages/flash/core/data/io/classification_input.py", line 79, in format_target
return self.target_formatter(target)
File "/usr/local/lib/python3.8/dist-packages/flash/core/data/utilities/classification.py", line 163, in __call__
return self.format(target)
File "/usr/local/lib/python3.8/dist-packages/flash/core/data/utilities/classification.py", line 182, in format
return self.label_to_idx[(target[0] if not isinstance(target, str) else target).strip()]
KeyError: '14'
I found that Label 14 is in the validation set but not in the training set.
Question
Is there a way to train on a subset of the classes but validate on all classes ?
What have you tried?
I have no idea how to workaround this...
What's your environment?
OS: [e.g. iOS, Linux, Win] Ubuntu 18. in docker
Packaging [e.g. pip, conda] pip
Version [e.g. 0.5.2.1] 0.6.0
The text was updated successfully, but these errors were encountered:
daMichaelB
changed the title
How can one train a ImageClassificationData if Class is in Validation-Set but not in Train-Set?
How can one train a ImageClassifier if Class is in Validation-Set but not in Train-Set?
Jan 21, 2022
These objects are usually inferred from the training data, but in cases where that inference is not possible (e.g. where can't efficiently get a list of all targets) we have begun to expose this object. So you could have for example:
ethanwharris
changed the title
How can one train a ImageClassifier if Class is in Validation-Set but not in Train-Set?
Ability to pass the TargetFormatter to use with classification data modules
Jan 28, 2022
❓ Questions and Help
What is your question?
I have a highly imbalanced dataset, where some minority classes are very rare. I put them ONLY into the validation set. I want to validate, if the model can classify them not to be in the majority class.
The Datamodule was created with:
As i understood, i can create the
ImageClassifier
with the number of ALL classes:However my training crashes at the beginning with
Validation sanity check:
. Tracelog:I found that Label 14 is in the validation set but not in the training set.
Question
Is there a way to train on a subset of the classes but validate on all classes ?
What have you tried?
I have no idea how to workaround this...
What's your environment?
The text was updated successfully, but these errors were encountered: