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.
It seems that the DataModule don't cast to torch tensors and don't prepare the batch.
As a workaround, and NOT specified in the docs - you can pass the labels as List[torch.Tensor].
However, you have create and tweak a custom loss function as follows:
defmy_loss(x, y):
# To make this work you have to pass the labels as List[torch.Tensor] from `from_filepaths`.# This not specified anywhere, since the examples show that you must pass List[int].assertisinstance(x, torch.Tensor), type(x)
assertisinstance(y, torch.Tensor), type(y)
assertx.shape==y.shape, (x.shape, y.shape)
# NOTE: even if you pass the tensor as torch.float it's automatically casted to torch.int64y=y.to(x) # labels have to be in floating point precision to compute BCEreturntorch.nn.functional.binary_cross_entropy_with_logits(x, y)
IMO, there should a unique way to pass labels either List[List[int]] or List[torch.Tensor].
The text was updated successfully, but these errors were encountered:
🐛 Bug
When I try to use the
ImageClassifationData
to solve a multi-label problem there's no clear way how to pass the labels data.Following the multi-class example in the documentation, I expect the mult-label to work as follows:
It seems that the
DataModule
don't cast to torch tensors and don't prepare the batch.As a workaround, and NOT specified in the docs - you can pass the labels as
List[torch.Tensor]
.However, you have create and tweak a custom loss function as follows:
IMO, there should a unique way to pass labels either
List[List[int]]
orList[torch.Tensor]
.The text was updated successfully, but these errors were encountered: