Skip to content

Dividing data into tasks from dataset of type torch.utils.data.dataset.Subset based on label #406

Answered by lrzpellegrini
akashtadwai asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Akash, that error basically means that the datasets you provide to nc_scenario must have a targets field. Alas, the Subset class found in PyTorch doesn't support it.

The targets field should be a list of int describing the class label of each pattern, which means that the size of that list must be equal to the number of patterns in the dataset.

You probably got your Subset from an original, bigger, Dataset: does the original dataset have a targets field? If it already has a targets field, then you can create the subset using AvalancheSubset instead of the Subset class from PyTorch:

subset = AvalancheSubset(original_dataset, indices=[...])

Let me know if this works for you. Also, if the…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@vlomonaco
Comment options

@akashtadwai
Comment options

@lrzpellegrini
Comment options

@akashtadwai
Comment options

@lrzpellegrini
Comment options

Answer selected by akashtadwai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants