{
  "id": 368166,
  "title": "What’s causing this error (tensorflow)",
  "url": "/competitions/g2net-detecting-continuous-gravitational-waves/discussion/368166",
  "author_name": "Samantha Hassal",
  "post_date": "2022-11-23T23:18:44.927000",
  "votes": 0,
  "comment_count": 1,
  "views": 0,
  "content": "<p>I’m using an image classifier to guess signal depth and SNR based on an image (simulated data)</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F8655184%2F365a1704d9dfeb48dbd527519e865a1e%2F0F18BB04-E51E-4050-8553-08E2CEEFCD70.jpeg?generation=1669245487118434&amp;alt=media\" alt=\"\"></p>\n<p>When I fit it to the data, I get this error:<br>\nInvalidArgumentError:  logits and labels must have the same first dimension, got logits shape [32,100] and labels shape [64]<br>\n     [[node sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits (defined at tmp/ipykernel_17/676913629.py:8) ]] [Op:__inference_train_function_6645]</p>\n<p>Function call stack:<br>\ntrain_function</p>\n<p>How do I fix?</p>",
  "messages": [
    {
      "id": 2041451,
      "postDate": "2022-11-24T00:36:23.407Z",
      "content": "<p>It looks like the training data is not in the right shape. I would first double-check that <code>y_train</code> contains a list of unique labels and then check the shape of your training inputs. Hope it helps!</p>",
      "rawMarkdown": "It looks like the training data is not in the right shape. I would first double-check that `y_train` contains a list of unique labels and then check the shape of your training inputs. Hope it helps!",
      "votes": 1
    },
    {
      "id": 2041413,
      "postDate": "2022-11-23T23:18:44.927Z",
      "content": "<p>I’m using an image classifier to guess signal depth and SNR based on an image (simulated data)</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F8655184%2F365a1704d9dfeb48dbd527519e865a1e%2F0F18BB04-E51E-4050-8553-08E2CEEFCD70.jpeg?generation=1669245487118434&amp;alt=media\" alt=\"\"></p>\n<p>When I fit it to the data, I get this error:<br>\nInvalidArgumentError:  logits and labels must have the same first dimension, got logits shape [32,100] and labels shape [64]<br>\n     [[node sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits (defined at tmp/ipykernel_17/676913629.py:8) ]] [Op:__inference_train_function_6645]</p>\n<p>Function call stack:<br>\ntrain_function</p>\n<p>How do I fix?</p>",
      "rawMarkdown": "I’m using an image classifier to guess signal depth and SNR based on an image (simulated data)\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F8655184%2F365a1704d9dfeb48dbd527519e865a1e%2F0F18BB04-E51E-4050-8553-08E2CEEFCD70.jpeg?generation=1669245487118434&alt=media)\n\nWhen I fit it to the data, I get this error:\nInvalidArgumentError:  logits and labels must have the same first dimension, got logits shape [32,100] and labels shape [64]\n\t [[node sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits (defined at tmp/ipykernel_17/676913629.py:8) ]] [Op:__inference_train_function_6645]\n\nFunction call stack:\ntrain_function\n\nHow do I fix?"
    }
  ],
  "comments": [
    {
      "id": 2041451,
      "author_name": "Francois Lemarchand",
      "author_url": "",
      "post_date": "2022-11-24T00:36:23.407000",
      "content": "<p>It looks like the training data is not in the right shape. I would first double-check that <code>y_train</code> contains a list of unique labels and then check the shape of your training inputs. Hope it helps!</p>",
      "votes": 1,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2041451": "It looks like the training data is not in the right shape. I would first double-check that `y_train` contains a list of unique labels and then check the shape of your training inputs. Hope it helps!",
    "2041413": "I’m using an image classifier to guess signal depth and SNR based on an image (simulated data)\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F8655184%2F365a1704d9dfeb48dbd527519e865a1e%2F0F18BB04-E51E-4050-8553-08E2CEEFCD70.jpeg?generation=1669245487118434&alt=media)\n\nWhen I fit it to the data, I get this error:\nInvalidArgumentError:  logits and labels must have the same first dimension, got logits shape [32,100] and labels shape [64]\n\t [[node sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits (defined at tmp/ipykernel_17/676913629.py:8) ]] [Op:__inference_train_function_6645]\n\nFunction call stack:\ntrain_function\n\nHow do I fix?"
  }
}