Skip to content

Dataset with multi target #954

Closed Answered by BenjaminBossan
MohammadJavadD asked this question in Q&A
Discussion options

You must be logged in to vote

I see, so your target contains multiple columns but you actually only need the first one. The best solution to this depends a bit on your data.

If you have control over X and y, and they are tensors or numpy arrays, this should just work: net.fit(X, y[:, 0]).

If you only have control over the dataset (e.g. because it comes from an external library), you could try to change its output. This could be through subclassing:

class MyDataset(ExternalDataset):
    def __getitem__(self, i):
        Xi, yi = super().__getitem__()
        return Xi, yi[0]

Or you could wrap the other dataset:

class MyDataset(torch.utils.data.Dataset):
    def __init__(self, external_dataset):
        self.external_da…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@BenjaminBossan
Comment options

@MohammadJavadD
Comment options

@BenjaminBossan
Comment options

Answer selected by MohammadJavadD
@BenjaminBossan
Comment options

@MohammadJavadD
Comment options

@MohammadJavadD
Comment options

@BenjaminBossan
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #953 on April 11, 2023 09:58.