{
  "id": 413035,
  "title": "Request to Include TensorFlow Operators in Submission Environment for Better Model Flexibility",
  "url": "/competitions/asl-fingerspelling/discussion/413035",
  "author_name": "Jude TCHAYE",
  "post_date": "2023-05-26T13:06:00.133000",
  "votes": 10,
  "comment_count": 7,
  "views": 0,
  "content": "<p>The submission environment does not support TensorFlow operators.</p>\n<p>It seems to have been the case in the previous competition as mentioned <a href=\"https://www.kaggle.com/competitions/asl-signs/discussion/390008#2199328\" target=\"_blank\">here</a>.</p>\n<p>This means for a submission to work, one should be able to convert their model to TFLite without using the <code>tf.lite.OpsSet.SELECT_TF_OPS</code> flag.</p>\n<pre><code>keras_model_converter = tf.lite.TFLiteConverter.from_keras_model(model)\n\nkeras_model_converter.target_spec.supported_ops = [\n    tf.lite.OpsSet.TFLITE_BUILTINS, \n    tf.lite.OpsSet.SELECT_TF_OPS  \n]\ntflite_model = keras_model_converter.convert()\n</code></pre>\n<p>The problem is that without the <code>SELECT_TF_OPS</code>flag, we are very limited in building our model.</p>\n<p>We can't use simple layers such as <code>tf.keras.layers.Embedding</code>, and simple operations like <code>tf.gather</code> or <code>tf.gather_nd</code> are not working, which makes it impossible to perform indexing on tensors.</p>\n<p>There is already constraints to guarantee that submitted models could potentially run on cell phones:</p>\n<ul>\n<li>Your model must perform inference in less than 5 hours.</li>\n<li>Your model must use less than 40 MB of storage space.</li>\n</ul>\n<p>Hence, we kindly request the organizers to include <strong>TensorFlow operators</strong> in the submission environment and allow contestants to ensure that their models satisfy the runtime constraints.</p>\n<p>Please upvote this thread if you agree with me😓.</p>",
  "messages": [
    {
      "id": 2275054,
      "postDate": "2023-05-26T13:06:00.133Z",
      "content": "<p>The submission environment does not support TensorFlow operators.</p>\n<p>It seems to have been the case in the previous competition as mentioned <a href=\"https://www.kaggle.com/competitions/asl-signs/discussion/390008#2199328\" target=\"_blank\">here</a>.</p>\n<p>This means for a submission to work, one should be able to convert their model to TFLite without using the <code>tf.lite.OpsSet.SELECT_TF_OPS</code> flag.</p>\n<pre><code>keras_model_converter = tf.lite.TFLiteConverter.from_keras_model(model)\n\nkeras_model_converter.target_spec.supported_ops = [\n    tf.lite.OpsSet.TFLITE_BUILTINS, \n    tf.lite.OpsSet.SELECT_TF_OPS  \n]\ntflite_model = keras_model_converter.convert()\n</code></pre>\n<p>The problem is that without the <code>SELECT_TF_OPS</code>flag, we are very limited in building our model.</p>\n<p>We can't use simple layers such as <code>tf.keras.layers.Embedding</code>, and simple operations like <code>tf.gather</code> or <code>tf.gather_nd</code> are not working, which makes it impossible to perform indexing on tensors.</p>\n<p>There is already constraints to guarantee that submitted models could potentially run on cell phones:</p>\n<ul>\n<li>Your model must perform inference in less than 5 hours.</li>\n<li>Your model must use less than 40 MB of storage space.</li>\n</ul>\n<p>Hence, we kindly request the organizers to include <strong>TensorFlow operators</strong> in the submission environment and allow contestants to ensure that their models satisfy the runtime constraints.</p>\n<p>Please upvote this thread if you agree with me😓.</p>",
      "rawMarkdown": "The submission environment does not support TensorFlow operators.\n\nIt seems to have been the case in the previous competition as mentioned [here](https://www.kaggle.com/competitions/asl-signs/discussion/390008#2199328).\n\nThis means for a submission to work, one should be able to convert their model to TFLite without using the `tf.lite.OpsSet.SELECT_TF_OPS` flag.\n\n\n```python\nkeras_model_converter = tf.lite.TFLiteConverter.from_keras_model(model)\n\nkeras_model_converter.target_spec.supported_ops = [\n    tf.lite.OpsSet.TFLITE_BUILTINS, \n    tf.lite.OpsSet.SELECT_TF_OPS  # You can't use this\n]\ntflite_model = keras_model_converter.convert()\n\n```\n\nThe problem is that without the `SELECT_TF_OPS `flag, we are very limited in building our model.\n\nWe can't use simple layers such as `tf.keras.layers.Embedding`, and simple operations like `tf.gather` or `tf.gather_nd` are not working, which makes it impossible to perform indexing on tensors.\n\nThere is already constraints to guarantee that submitted models could potentially run on cell phones:\n\n- Your model must perform inference in less than 5 hours.\n- Your model must use less than 40 MB of storage space.\n\nHence, we kindly request the organizers to include **TensorFlow operators** in the submission environment and allow contestants to ensure that their models satisfy the runtime constraints.\n\nPlease upvote this thread if you agree with me😓.",
      "votes": 10
    },
    {
      "id": 2276212,
      "postDate": "2023-05-26T15:21:26.983Z",
      "content": "<p>Meanwhile, I can confirm that <code>tf.gather</code> works well in TFLIte without TF_OPS (verified in the previous competition)</p>",
      "rawMarkdown": "Meanwhile, I can confirm that `tf.gather` works well in TFLIte without TF_OPS (verified in the previous competition)",
      "votes": 1,
      "replies": [
        {
          "id": 2277725,
          "postDate": "2023-05-28T02:16:15.213Z",
          "content": "<p>Yeah I know but it has many weird bugs that can appear without any explanation.  Check this GitHub issue: <a href=\"https://github.com/tensorflow/tensorflow/issues/42410\" target=\"_blank\">https://github.com/tensorflow/tensorflow/issues/42410</a></p>",
          "rawMarkdown": "Yeah I know but it has many weird bugs that can appear without any explanation.  Check this GitHub issue: https://github.com/tensorflow/tensorflow/issues/42410"
        }
      ]
    },
    {
      "id": 2276193,
      "postDate": "2023-05-26T15:12:16.843Z",
      "content": "<p>It is also important to note that you may include tf.lite.OpsSet.SELECT_TF_OPS but if not used in the model the submission will be successful as in this notebook: <a href=\"https://www.kaggle.com/code/chack3/pytorch-simple-model\" target=\"_blank\">https://www.kaggle.com/code/chack3/pytorch-simple-model</a></p>",
      "rawMarkdown": "It is also important to note that you may include tf.lite.OpsSet.SELECT_TF_OPS but if not used in the model the submission will be successful as in this notebook: https://www.kaggle.com/code/chack3/pytorch-simple-model",
      "votes": 1
    },
    {
      "id": 2276233,
      "postDate": "2023-05-26T15:36:02.563Z",
      "content": "<p>Thanks for sharing the convert code, it can helped to training the model in different form.</p>",
      "rawMarkdown": "Thanks for sharing the convert code, it can helped to training the model in different form."
    },
    {
      "id": 2301727,
      "postDate": "2023-06-14T06:13:28.133Z",
      "rawMarkdown": "",
      "isDeleted": true
    },
    {
      "id": 2276230,
      "postDate": "2023-05-26T15:34:10.573Z",
      "rawMarkdown": "",
      "isDeleted": true
    },
    {
      "id": 2275101,
      "postDate": "2023-05-26T14:01:38.600Z",
      "rawMarkdown": "",
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 2276212,
      "author_name": "Mykola",
      "author_url": "",
      "post_date": "2023-05-26T15:21:26.983000",
      "content": "<p>Meanwhile, I can confirm that <code>tf.gather</code> works well in TFLIte without TF_OPS (verified in the previous competition)</p>",
      "votes": 1,
      "replies": [
        {
          "id": 2277725,
          "author_name": "Jude TCHAYE",
          "author_url": "",
          "post_date": "2023-05-28T02:16:15.213000",
          "content": "<p>Yeah I know but it has many weird bugs that can appear without any explanation.  Check this GitHub issue: <a href=\"https://github.com/tensorflow/tensorflow/issues/42410\" target=\"_blank\">https://github.com/tensorflow/tensorflow/issues/42410</a></p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 2276193,
      "author_name": "Jude TCHAYE",
      "author_url": "",
      "post_date": "2023-05-26T15:12:16.843000",
      "content": "<p>It is also important to note that you may include tf.lite.OpsSet.SELECT_TF_OPS but if not used in the model the submission will be successful as in this notebook: <a href=\"https://www.kaggle.com/code/chack3/pytorch-simple-model\" target=\"_blank\">https://www.kaggle.com/code/chack3/pytorch-simple-model</a></p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 2276233,
      "author_name": "Dewei Chen",
      "author_url": "",
      "post_date": "2023-05-26T15:36:02.563000",
      "content": "<p>Thanks for sharing the convert code, it can helped to training the model in different form.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 2301727,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-06-14T06:13:28.133000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 2276230,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-05-26T15:34:10.573000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 2275101,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-05-26T14:01:38.600000",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2275054": "The submission environment does not support TensorFlow operators.\n\nIt seems to have been the case in the previous competition as mentioned [here](https://www.kaggle.com/competitions/asl-signs/discussion/390008#2199328).\n\nThis means for a submission to work, one should be able to convert their model to TFLite without using the `tf.lite.OpsSet.SELECT_TF_OPS` flag.\n\n\n```python\nkeras_model_converter = tf.lite.TFLiteConverter.from_keras_model(model)\n\nkeras_model_converter.target_spec.supported_ops = [\n    tf.lite.OpsSet.TFLITE_BUILTINS, \n    tf.lite.OpsSet.SELECT_TF_OPS  # You can't use this\n]\ntflite_model = keras_model_converter.convert()\n\n```\n\nThe problem is that without the `SELECT_TF_OPS `flag, we are very limited in building our model.\n\nWe can't use simple layers such as `tf.keras.layers.Embedding`, and simple operations like `tf.gather` or `tf.gather_nd` are not working, which makes it impossible to perform indexing on tensors.\n\nThere is already constraints to guarantee that submitted models could potentially run on cell phones:\n\n- Your model must perform inference in less than 5 hours.\n- Your model must use less than 40 MB of storage space.\n\nHence, we kindly request the organizers to include **TensorFlow operators** in the submission environment and allow contestants to ensure that their models satisfy the runtime constraints.\n\nPlease upvote this thread if you agree with me😓.",
    "2276212": "Meanwhile, I can confirm that `tf.gather` works well in TFLIte without TF_OPS (verified in the previous competition)",
    "2276193": "It is also important to note that you may include tf.lite.OpsSet.SELECT_TF_OPS but if not used in the model the submission will be successful as in this notebook: https://www.kaggle.com/code/chack3/pytorch-simple-model",
    "2276233": "Thanks for sharing the convert code, it can helped to training the model in different form.",
    "2301727": "",
    "2276230": "",
    "2275101": ""
  }
}