Multi-label classification problem script testing dataset

vahvero: <p>I have very difficult multi-label problem for which I try to fit a residual network. I would like to test this script with a small multi-label dataset  from torchvision library. However, when trying to search these datasets, only reference given is the original paper where these datasets were introduced. Seaching these datasets is cumbersome. Is there a suitable dataset in vision, or must I implement such dataset myself?</p>
<p>Simplification of the script.</p>
<pre><code class="lang-auto">num_classes = 7
model = resnet34(
    weights="DEFAULT",
)

features = model.fc.in_features

model.fc = nn.Sequential(
    nn.Linear(features, features),
    nn.ReLU(),
    nn.Linear(features, num_classes),
    nn.Sigmoid(),
)

loss_fn = nn.BCEWithLogitsLoss()
# This type of input with bsize = 16
target = torch.tensor([[0, 0, 1, 0, 1, 0, 1]], dtype=torch.float32)
img = torch.rand(3, 256, 256, dtype=torch.float32)
predicted = model(img.unsqueeze(0))
loss = loss_fn(predicted, target)
</code></pre>

ptrblck: <p>You can test your multi-class classification and model via some small classification datasets such as <code>CIFAR10</code>, <code>CIFAR100</code>, or <code>MNIST</code>. There could be seem as smoke tests but <code>torchvision</code> would download them for you so you wouldn’t need to search for them.</p>

vahvero: <p>From what I have understood, these datasets have single correct label, not multiple. They do not fit to my use case, as I have multi-class and multi-label problem.</p>
<p>I might have been unclear previously. A dataset that fits my purpose would have multiple correct labels. Let’s say, a dataset with a large amount of colorful T-shirt images. Then I would predict that a T-shirt would have red-blue-green colors, or label of <code>[0., 0., 0., 1., 0., 1., 1.]</code>  if the labels would contain information on the colors of the T-shirts.</p>
<p>EDIT: I might be wrong myself as CIFAR-100 contains superclass and multiple classes for this superclass. I might be able to combine these and have superclass and class input array. Will required some work thought.</p>

ptrblck: <p>You are right and I didn’t realize you are looking for a multi-label dataset, sorry.<br>
I’m not aware of a CIFAR-like multi-label dataset and think that often tabular datasets are used for these use cases as an example (e.g. movie genre datasets).<br>
<a href="https://paperswithcode.com/task/multi-label-classification">paperswithcode</a> mentions a few datasets, but I would guess you might need to download them offline due to their size.</p>

vahvero: <p>I managed to find a movie poster genre dataset that should fit multi-label requirement in</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://www.kaggle.com/datasets/neha1703/movie-genre-from-its-poster/versions/3?resource=download">
  <header class="source">
      <img src="https://www.kaggle.com/static/images/favicon.ico" class="site-icon" width="32" height="32">

      <a href="https://www.kaggle.com/datasets/neha1703/movie-genre-from-its-poster/versions/3?resource=download" target="_blank" rel="noopener nofollow ugc">kaggle.com</a>
  </header>

  <article class="onebox-body">
    <img src="https://storage.googleapis.com/kaggle-datasets-images/1365/2460/229bfb5d3dd1a49cc5ac899c45ca2213/dataset-card.png" class="thumbnail onebox-avatar" width="500" height="500">

<h3><a href="https://www.kaggle.com/datasets/neha1703/movie-genre-from-its-poster/versions/3?resource=download" target="_blank" rel="noopener nofollow ugc">Movie Genre from its Poster</a></h3>

  <p>Predicting the Genre of the movie by analyzing its poster</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p>Working this to a <code>Dataset</code> requires a bit of work however.</p>