{
  "id": 156407,
  "title": "Problem with fastai library",
  "url": "/competitions/siim-isic-melanoma-classification/discussion/156407",
  "author_name": "",
  "post_date": "2020-06-05T21:41:19.569640800Z",
  "votes": null,
  "comment_count": 1,
  "views": 0,
  "content": "<p>Hello</p>\n\n<p>I am trying to create a model with the fastai library, I generate the dataset using the following command</p>\n\n<p><code>data = (ImageList.from_csv(path, 'train.csv', folder='train', suffix='.jpg')\n        .split_by_rand_pct()\n        .label_from_df(cols=7)\n        .transform(tfms, size=64)\n        .databunch(bs=64)\n        .normalize(imagenet_stats))</code></p>\n\n<p>And I create the learner by</p>\n\n<p><code>learn = cnn_learner(data, models.resnet34, metrics=auc_roc_score)</code></p>\n\n<p>When I try to train by</p>\n\n<p><code>learn.fit_one_cycle(5, slice(1e-2))</code></p>\n\n<p>I get the following error</p>\n\n<p><code>RuntimeError: The size of tensor a  must match the size of tensor b at non-singleton dimension 1</code></p>\n\n<p>However, if I create the learner without specifying the metric, I don't get the error</p>\n\n<p><code>learn = cnn_learner(data, models.resnet34)</code></p>\n\n<p>Anyone know why and could you help me</p>\n\n<p>Thanks in advance</p>",
  "messages": [
    {
      "id": "875514",
      "postDate": "06/05/2020 21:41:19",
      "content": "<p>Hello</p>\n\n<p>I am trying to create a model with the fastai library, I generate the dataset using the following command</p>\n\n<p><code>data = (ImageList.from_csv(path, 'train.csv', folder='train', suffix='.jpg')\n        .split_by_rand_pct()\n        .label_from_df(cols=7)\n        .transform(tfms, size=64)\n        .databunch(bs=64)\n        .normalize(imagenet_stats))</code></p>\n\n<p>And I create the learner by</p>\n\n<p><code>learn = cnn_learner(data, models.resnet34, metrics=auc_roc_score)</code></p>\n\n<p>When I try to train by</p>\n\n<p><code>learn.fit_one_cycle(5, slice(1e-2))</code></p>\n\n<p>I get the following error</p>\n\n<p><code>RuntimeError: The size of tensor a  must match the size of tensor b at non-singleton dimension 1</code></p>\n\n<p>However, if I create the learner without specifying the metric, I don't get the error</p>\n\n<p><code>learn = cnn_learner(data, models.resnet34)</code></p>\n\n<p>Anyone know why and could you help me</p>\n\n<p>Thanks in advance</p>",
      "rawMarkdown": "Hello\n\nI am trying to create a model with the fastai library, I generate the dataset using the following command\n\n`data = (ImageList.from_csv(path, 'train.csv', folder='train', suffix='.jpg')\n        .split_by_rand_pct()\n        .label_from_df(cols=7)\n        .transform(tfms, size=64)\n        .databunch(bs=64)\n        .normalize(imagenet_stats)) `\n\nAnd I create the learner by\n\n`learn = cnn_learner(data, models.resnet34, metrics=auc_roc_score)`\n\nWhen I try to train by\n\n`learn.fit_one_cycle(5, slice(1e-2))`\n\nI get the following error\n\n`RuntimeError: The size of tensor a  must match the size of tensor b at non-singleton dimension 1`\n\nHowever, if I create the learner without specifying the metric, I don't get the error\n\n`learn = cnn_learner(data, models.resnet34)`\n\nAnyone know why and could you help me\n\nThanks in advance",
      "votes": null
    },
    {
      "id": "875545",
      "postDate": "06/05/2020 22:25:24",
      "content": "<p>I have found the solution. <code>auc_roc_score</code> must be replaced by <code>AUROC()</code></p>",
      "rawMarkdown": "I have found the solution. `auc_roc_score` must be replaced by `AUROC()`",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 875545,
      "author_name": "maximofn",
      "author_url": "",
      "post_date": "06/05/2020 22:25:24",
      "content": "<p>I have found the solution. <code>auc_roc_score</code> must be replaced by <code>AUROC()</code></p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "875514": "Hello\n\nI am trying to create a model with the fastai library, I generate the dataset using the following command\n\n`data = (ImageList.from_csv(path, 'train.csv', folder='train', suffix='.jpg')\n        .split_by_rand_pct()\n        .label_from_df(cols=7)\n        .transform(tfms, size=64)\n        .databunch(bs=64)\n        .normalize(imagenet_stats)) `\n\nAnd I create the learner by\n\n`learn = cnn_learner(data, models.resnet34, metrics=auc_roc_score)`\n\nWhen I try to train by\n\n`learn.fit_one_cycle(5, slice(1e-2))`\n\nI get the following error\n\n`RuntimeError: The size of tensor a  must match the size of tensor b at non-singleton dimension 1`\n\nHowever, if I create the learner without specifying the metric, I don't get the error\n\n`learn = cnn_learner(data, models.resnet34)`\n\nAnyone know why and could you help me\n\nThanks in advance",
    "875545": "I have found the solution. `auc_roc_score` must be replaced by `AUROC()`"
  },
  "source": "meta"
}