{
  "id": 413121,
  "title": "Help! Conv1D with expanding dims error",
  "url": "/competitions/asl-fingerspelling/discussion/413121",
  "author_name": "Jon",
  "post_date": "2023-05-27T03:58:54.692000",
  "votes": 0,
  "comment_count": 2,
  "views": 0,
  "content": "<p>Hello,</p>\n<p>I am able to submit a model that has a dense layer to 59. Assuming the input has shape NxFeatures, my output is nx59.</p>\n<p>However i am not able to submit a model where I expand the first dimension of the input to obtain 1xNxFeatures to then run a Conv1D.</p>\n<p>To squeeze the output I run</p>\n<p>output = output[0].</p>\n<p>My code looks like this:</p>\n<p>inputs = tf.keras.Input(shape=(Features))<br>\nx = tf.expand_dims(inputs, axis=0)<br>\nx = tf.keras.layers.Conv1D(59, 1, padding='same')(inputs)<br>\nx = x[0]<br>\nmodel = tf.keras.Model(inputs=inputs, outputs=x)</p>\n<p>Any help would be great.</p>",
  "messages": [
    {
      "id": 2276833,
      "postDate": "2023-05-27T08:35:34.013Z",
      "content": "<p>Hi,</p>\n<p>I'm also had an issue with <code>tf.expand_dims</code>, you may to try <code>x = inputs[None]</code> instead of <code>x = tf.expand_dims(inputs, axis=0)</code><br>\nIt <a href=\"https://www.kaggle.com/competitions/asl-fingerspelling/discussion/409722#2276829\" target=\"_blank\">helped me</a></p>",
      "rawMarkdown": "Hi,\n\nI'm also had an issue with `tf.expand_dims`, you may to try `x = inputs[None]` instead of `x = tf.expand_dims(inputs, axis=0)`\nIt [helped me](https://www.kaggle.com/competitions/asl-fingerspelling/discussion/409722#2276829)",
      "replies": [
        {
          "id": 2277655,
          "postDate": "2023-05-28T00:22:08.230Z",
          "content": "<p>thanks! it worked</p>",
          "rawMarkdown": "thanks! it worked"
        }
      ]
    },
    {
      "id": 2276604,
      "postDate": "2023-05-27T03:58:54.693Z",
      "content": "<p>Hello,</p>\n<p>I am able to submit a model that has a dense layer to 59. Assuming the input has shape NxFeatures, my output is nx59.</p>\n<p>However i am not able to submit a model where I expand the first dimension of the input to obtain 1xNxFeatures to then run a Conv1D.</p>\n<p>To squeeze the output I run</p>\n<p>output = output[0].</p>\n<p>My code looks like this:</p>\n<p>inputs = tf.keras.Input(shape=(Features))<br>\nx = tf.expand_dims(inputs, axis=0)<br>\nx = tf.keras.layers.Conv1D(59, 1, padding='same')(inputs)<br>\nx = x[0]<br>\nmodel = tf.keras.Model(inputs=inputs, outputs=x)</p>\n<p>Any help would be great.</p>",
      "rawMarkdown": "Hello,\n\nI am able to submit a model that has a dense layer to 59. Assuming the input has shape NxFeatures, my output is nx59.\n\nHowever i am not able to submit a model where I expand the first dimension of the input to obtain 1xNxFeatures to then run a Conv1D.\n\nTo squeeze the output I run\n\noutput = output[0].\n\nMy code looks like this:\n\ninputs = tf.keras.Input(shape=(Features))\nx = tf.expand_dims(inputs, axis=0)\nx = tf.keras.layers.Conv1D(59, 1, padding='same')(inputs)\nx = x[0]\nmodel = tf.keras.Model(inputs=inputs, outputs=x)\n\nAny help would be great."
    }
  ],
  "comments": [
    {
      "id": 2276833,
      "author_name": "Kolya Forrat",
      "author_url": "",
      "post_date": "2023-05-27T08:35:34.013000",
      "content": "<p>Hi,</p>\n<p>I'm also had an issue with <code>tf.expand_dims</code>, you may to try <code>x = inputs[None]</code> instead of <code>x = tf.expand_dims(inputs, axis=0)</code><br>\nIt <a href=\"https://www.kaggle.com/competitions/asl-fingerspelling/discussion/409722#2276829\" target=\"_blank\">helped me</a></p>",
      "votes": 0,
      "replies": [
        {
          "id": 2277655,
          "author_name": "Jon",
          "author_url": "",
          "post_date": "2023-05-28T00:22:08.230000",
          "content": "<p>thanks! it worked</p>",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2276833": "Hi,\n\nI'm also had an issue with `tf.expand_dims`, you may to try `x = inputs[None]` instead of `x = tf.expand_dims(inputs, axis=0)`\nIt [helped me](https://www.kaggle.com/competitions/asl-fingerspelling/discussion/409722#2276829)",
    "2276604": "Hello,\n\nI am able to submit a model that has a dense layer to 59. Assuming the input has shape NxFeatures, my output is nx59.\n\nHowever i am not able to submit a model where I expand the first dimension of the input to obtain 1xNxFeatures to then run a Conv1D.\n\nTo squeeze the output I run\n\noutput = output[0].\n\nMy code looks like this:\n\ninputs = tf.keras.Input(shape=(Features))\nx = tf.expand_dims(inputs, axis=0)\nx = tf.keras.layers.Conv1D(59, 1, padding='same')(inputs)\nx = x[0]\nmodel = tf.keras.Model(inputs=inputs, outputs=x)\n\nAny help would be great."
  }
}