{
  "id": 402545,
  "title": "Nobuco, - pytorch2tf conversion made easy.",
  "url": "/competitions/asl-signs/discussion/402545",
  "author_name": "",
  "post_date": "2023-04-18T19:59:22.157581700Z",
  "votes": 7,
  "comment_count": 3,
  "views": 0,
  "content": "<p>I stumbled upon a library which was released just couple of days ago, it's a library that converts pytorch graph op-by-op resulting in the equivalent keras graph, take a look <a href=\"https://github.com/AlexanderLutsenko/nobuco\" target=\"_blank\">nobuco</a></p>\n<p>I was trying to convert my model to TF via torch.onnx.export and onnx_tf, however I have some custom ops that were converted in not a very efficient way resulting in ~50% overall slowdown, and with nobuco I was able to successfully convert my model to keras without losing performance.</p>\n<pre><code>dummy_input = torch.rand(size=(L, point_dim))\npytorch_module = MyModule().eval()\n\nkeras_model = nobuco.pytorch_to_keras(\n    pytorch_module,\n    args=[dummy_input],\n    inputs_channel_order=ChannelOrder.PYTORCH,\n    outputs_channel_order=ChannelOrder.TENSORFLOW\n)\n</code></pre>",
  "messages": [
    {
      "id": "2226286",
      "postDate": "04/18/2023 19:59:22",
      "content": "<p>I stumbled upon a library which was released just couple of days ago, it's a library that converts pytorch graph op-by-op resulting in the equivalent keras graph, take a look <a href=\"https://github.com/AlexanderLutsenko/nobuco\" target=\"_blank\">nobuco</a></p>\n<p>I was trying to convert my model to TF via torch.onnx.export and onnx_tf, however I have some custom ops that were converted in not a very efficient way resulting in ~50% overall slowdown, and with nobuco I was able to successfully convert my model to keras without losing performance.</p>\n<pre><code>dummy_input = torch.rand(size=(L, point_dim))\npytorch_module = MyModule().eval()\n\nkeras_model = nobuco.pytorch_to_keras(\n    pytorch_module,\n    args=[dummy_input],\n    inputs_channel_order=ChannelOrder.PYTORCH,\n    outputs_channel_order=ChannelOrder.TENSORFLOW\n)\n</code></pre>",
      "rawMarkdown": "I stumbled upon a library which was released just couple of days ago, it's a library that converts pytorch graph op-by-op resulting in the equivalent keras graph, take a look [nobuco](https://github.com/AlexanderLutsenko/nobuco)\n\nI was trying to convert my model to TF via torch.onnx.export and onnx_tf, however I have some custom ops that were converted in not a very efficient way resulting in ~50% overall slowdown, and with nobuco I was able to successfully convert my model to keras without losing performance.\n\n```\ndummy_input = torch.rand(size=(L, point_dim))\npytorch_module = MyModule().eval()\n\nkeras_model = nobuco.pytorch_to_keras(\n    pytorch_module,\n    args=[dummy_input],\n    inputs_channel_order=ChannelOrder.PYTORCH,\n    outputs_channel_order=ChannelOrder.TENSORFLOW\n)\n```",
      "votes": null
    },
    {
      "id": "2237809",
      "postDate": "04/28/2023 01:20:02",
      "content": "<p>What is point_dim？Is that embedding size?</p>",
      "rawMarkdown": "What is point_dim？Is that embedding size?",
      "votes": null
    },
    {
      "id": "2237900",
      "postDate": "04/28/2023 03:52:20",
      "content": "<p>It depends on what nn.Module you want to convert, - dummy_input is just a random tensor that has certain dimensions that correspond to the input shape of pytorch_module</p>",
      "rawMarkdown": "It depends on what nn.Module you want to convert, - dummy_input is just a random tensor that has certain dimensions that correspond to the input shape of pytorch_module",
      "votes": null
    },
    {
      "id": "2246998",
      "postDate": "05/05/2023 15:54:40",
      "content": "<p><a href=\"https://www.kaggle.com/martynoveduard\" target=\"_blank\">@martynoveduard</a> thank you for sharing this! :) Nobuco is a great way to convert PyTorch models to TensorFlow. But sometimes a large number of errors appear during the conversion.</p>",
      "rawMarkdown": "martynoveduard thank you for sharing this! :) Nobuco is a great way to convert PyTorch models to TensorFlow. But sometimes a large number of errors appear during the conversion.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2237809,
      "author_name": "jacksonyou",
      "author_url": "",
      "post_date": "04/28/2023 01:20:02",
      "content": "<p>What is point_dim？Is that embedding size?</p>",
      "votes": null,
      "replies": [
        {
          "id": 2237900,
          "author_name": "martynoveduard",
          "author_url": "",
          "post_date": "04/28/2023 03:52:20",
          "content": "<p>It depends on what nn.Module you want to convert, - dummy_input is just a random tensor that has certain dimensions that correspond to the input shape of pytorch_module</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 2246998,
      "author_name": "ivanisaev",
      "author_url": "",
      "post_date": "05/05/2023 15:54:40",
      "content": "<p><a href=\"https://www.kaggle.com/martynoveduard\" target=\"_blank\">@martynoveduard</a> thank you for sharing this! :) Nobuco is a great way to convert PyTorch models to TensorFlow. But sometimes a large number of errors appear during the conversion.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2226286": "I stumbled upon a library which was released just couple of days ago, it's a library that converts pytorch graph op-by-op resulting in the equivalent keras graph, take a look [nobuco](https://github.com/AlexanderLutsenko/nobuco)\n\nI was trying to convert my model to TF via torch.onnx.export and onnx_tf, however I have some custom ops that were converted in not a very efficient way resulting in ~50% overall slowdown, and with nobuco I was able to successfully convert my model to keras without losing performance.\n\n```\ndummy_input = torch.rand(size=(L, point_dim))\npytorch_module = MyModule().eval()\n\nkeras_model = nobuco.pytorch_to_keras(\n    pytorch_module,\n    args=[dummy_input],\n    inputs_channel_order=ChannelOrder.PYTORCH,\n    outputs_channel_order=ChannelOrder.TENSORFLOW\n)\n```",
    "2237809": "What is point_dim？Is that embedding size?",
    "2237900": "It depends on what nn.Module you want to convert, - dummy_input is just a random tensor that has certain dimensions that correspond to the input shape of pytorch_module",
    "2246998": "martynoveduard thank you for sharing this! :) Nobuco is a great way to convert PyTorch models to TensorFlow. But sometimes a large number of errors appear during the conversion."
  },
  "source": "meta"
}