Dataset with multi target #954
-
Hi, my dataset returns a tuple of the target class and some more info about the sample, for example, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
(I converted this to a Discussion since we want to test the feature, I hope you don't mind). This question is difficult to answer with so little information. Do you have a multiclass classification problem? In that case, it should just work if you have a 2d tensor as target. Of course, the labels should be encoded, so something like this: >>> target
tensor([[0, 1, 2],
[3, 0, 1],
[2, 3, 0],
...
[1, 2, 3],
[0, 1, 2]]) Of course, your criterion should be able to deal with this kind of target. If you have more details, I might be able to provide a more complete solution. |
Beta Was this translation helpful? Give feedback.
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
andy
, 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:
Or you could wrap the other dataset: