{
  "id": 157135,
  "title": "TF dynamic dimension issue",
  "url": "/competitions/siim-isic-melanoma-classification/discussion/157135",
  "author_name": "",
  "post_date": "2020-06-09T12:27:14.475379300Z",
  "votes": 1,
  "comment_count": 2,
  "views": 0,
  "content": "<p>I was experimenting with custom losses when faced this issue:\n<code>UnimplementedError: {{function_node __inference_distributed_function_448013}} Compilation failure: Dynamic dimension on sorting dimension is not supported\n    TPU compilation failed\n     [[{{node tpu_compile_succeeded_assert/_9937966356354540212/_10}}]]</code>\nIn my case, dynamic dimension is batch_size.  I've tried various code, but failed in the end :) \nDid anyone face this issue? Did you resolve it?</p>",
  "messages": [
    {
      "id": "879377",
      "postDate": "06/09/2020 12:27:14",
      "content": "<p>I was experimenting with custom losses when faced this issue:\n<code>UnimplementedError: {{function_node __inference_distributed_function_448013}} Compilation failure: Dynamic dimension on sorting dimension is not supported\n    TPU compilation failed\n     [[{{node tpu_compile_succeeded_assert/_9937966356354540212/_10}}]]</code>\nIn my case, dynamic dimension is batch_size.  I've tried various code, but failed in the end :) \nDid anyone face this issue? Did you resolve it?</p>",
      "rawMarkdown": "I was experimenting with custom losses when faced this issue:\n`UnimplementedError: {{function_node __inference_distributed_function_448013}} Compilation failure: Dynamic dimension on sorting dimension is not supported\n\tTPU compilation failed\n\t [[{{node tpu_compile_succeeded_assert/_9937966356354540212/_10}}]]`\nIn my case, dynamic dimension is batch_size.  I've tried various code, but failed in the end :) \nDid anyone face this issue? Did you resolve it?",
      "votes": null
    },
    {
      "id": "881635",
      "postDate": "06/11/2020 08:16:18",
      "content": "<p>Can you post minimal code?</p>",
      "rawMarkdown": "Can you post minimal code?",
      "votes": null
    },
    {
      "id": "881906",
      "postDate": "06/11/2020 13:19:41",
      "content": "<p>```\ndef some_loss(y_true, y_pred):\n    # Extract 1s\n    pos = tf.boolean_mask(y_pred, tf.math.not_equal(y_true, tf.constant(0, dtype=tf.float32)))\n    # Extract 0s\n    neg = tf.boolean_mask(y_pred, tf.math.equal(y_true, tf.constant(0, dtype=tf.float32)))</p>\n\n<pre><code>pos = tf.reshape(pos, [-1,1])\nneg = tf.reshape(neg, [1,-1])\nloss = ###some math operations###\n</code></pre>\n\n<p>return loss\n```</p>",
      "rawMarkdown": "```\ndef some_loss(y_true, y_pred):\n    # Extract 1s\n    pos = tf.boolean_mask(y_pred, tf.math.not_equal(y_true, tf.constant(0, dtype=tf.float32)))\n    # Extract 0s\n    neg = tf.boolean_mask(y_pred, tf.math.equal(y_true, tf.constant(0, dtype=tf.float32)))\n\n    pos = tf.reshape(pos, [-1,1])\n    neg = tf.reshape(neg, [1,-1])\n    loss = ###some math operations###\nreturn loss\n```",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 881635,
      "author_name": "aakashnain",
      "author_url": "",
      "post_date": "06/11/2020 08:16:18",
      "content": "<p>Can you post minimal code?</p>",
      "votes": null,
      "replies": [
        {
          "id": 881906,
          "author_name": "stanislavblinov",
          "author_url": "",
          "post_date": "06/11/2020 13:19:41",
          "content": "<p>```\ndef some_loss(y_true, y_pred):\n    # Extract 1s\n    pos = tf.boolean_mask(y_pred, tf.math.not_equal(y_true, tf.constant(0, dtype=tf.float32)))\n    # Extract 0s\n    neg = tf.boolean_mask(y_pred, tf.math.equal(y_true, tf.constant(0, dtype=tf.float32)))</p>\n\n<pre><code>pos = tf.reshape(pos, [-1,1])\nneg = tf.reshape(neg, [1,-1])\nloss = ###some math operations###\n</code></pre>\n\n<p>return loss\n```</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "879377": "I was experimenting with custom losses when faced this issue:\n`UnimplementedError: {{function_node __inference_distributed_function_448013}} Compilation failure: Dynamic dimension on sorting dimension is not supported\n\tTPU compilation failed\n\t [[{{node tpu_compile_succeeded_assert/_9937966356354540212/_10}}]]`\nIn my case, dynamic dimension is batch_size.  I've tried various code, but failed in the end :) \nDid anyone face this issue? Did you resolve it?",
    "881635": "Can you post minimal code?",
    "881906": "```\ndef some_loss(y_true, y_pred):\n    # Extract 1s\n    pos = tf.boolean_mask(y_pred, tf.math.not_equal(y_true, tf.constant(0, dtype=tf.float32)))\n    # Extract 0s\n    neg = tf.boolean_mask(y_pred, tf.math.equal(y_true, tf.constant(0, dtype=tf.float32)))\n\n    pos = tf.reshape(pos, [-1,1])\n    neg = tf.reshape(neg, [1,-1])\n    loss = ###some math operations###\nreturn loss\n```"
  },
  "source": "meta"
}