{
  "id": 500782,
  "title": " [solved] Loss functions or optimized model weights affect model performance?",
  "url": "/competitions/birdclef-2024/discussion/500782",
  "author_name": "2g",
  "post_date": "2024-05-06T22:54:34.704000",
  "votes": 1,
  "comment_count": 0,
  "views": 0,
  "content": "<p>[6/13] The solution can be found in the method described <a href=\"https://discuss.pytorch.org/t/different-inference-time-for-the-same-model-trained-on-different-datasets/162687\" target=\"_blank\">here</a>.</p>\n<p>Do loss functions or optimized model weights affect inference performance?</p>\n<p>I used these notebook (<a href=\"https://www.kaggle.com/code/zijiangyang1116/birdclef-24-efficientnetb0-pytorch-train\" target=\"_blank\">train</a>, <a href=\"https://www.kaggle.com/code/zijiangyang1116/birdclef-24-inference-with-onnx\" target=\"_blank\">infer with ONNX</a>) for training and inference.  When I changed the loss function from nn.CrossEntropyLoss to nn.BCEWithLogitsLoss(), the inference time increased from 2s/batch to 10s/batch or more.  (Performance during TRAINING was not changed）</p>\n<p>If you know the cause of the performance degradation and the countermeasure for it, please let me know.</p>\n<p><a href=\"https://www.kaggle.com/zijiangyang1116\" target=\"_blank\">@zijiangyang1116</a>  thank you for sharing very useful notebook!）</p>",
  "messages": [
    {
      "id": 2797787,
      "postDate": "2024-05-06T22:54:34.703Z",
      "content": "<p>[6/13] The solution can be found in the method described <a href=\"https://discuss.pytorch.org/t/different-inference-time-for-the-same-model-trained-on-different-datasets/162687\" target=\"_blank\">here</a>.</p>\n<p>Do loss functions or optimized model weights affect inference performance?</p>\n<p>I used these notebook (<a href=\"https://www.kaggle.com/code/zijiangyang1116/birdclef-24-efficientnetb0-pytorch-train\" target=\"_blank\">train</a>, <a href=\"https://www.kaggle.com/code/zijiangyang1116/birdclef-24-inference-with-onnx\" target=\"_blank\">infer with ONNX</a>) for training and inference.  When I changed the loss function from nn.CrossEntropyLoss to nn.BCEWithLogitsLoss(), the inference time increased from 2s/batch to 10s/batch or more.  (Performance during TRAINING was not changed）</p>\n<p>If you know the cause of the performance degradation and the countermeasure for it, please let me know.</p>\n<p><a href=\"https://www.kaggle.com/zijiangyang1116\" target=\"_blank\">@zijiangyang1116</a>  thank you for sharing very useful notebook!）</p>",
      "rawMarkdown": "[6/13] The solution can be found in the method described [here](https://discuss.pytorch.org/t/different-inference-time-for-the-same-model-trained-on-different-datasets/162687).\n\n\n\n\n\n\n\nDo loss functions or optimized model weights affect inference performance?\n\nI used these notebook ([train](https://www.kaggle.com/code/zijiangyang1116/birdclef-24-efficientnetb0-pytorch-train), [infer with ONNX](https://www.kaggle.com/code/zijiangyang1116/birdclef-24-inference-with-onnx)) for training and inference.  When I changed the loss function from nn.CrossEntropyLoss to nn.BCEWithLogitsLoss(), the inference time increased from 2s/batch to 10s/batch or more.  (Performance during TRAINING was not changed）\n\nIf you know the cause of the performance degradation and the countermeasure for it, please let me know.\n\n@zijiangyang1116  thank you for sharing very useful notebook!）",
      "votes": 1
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "2797787": "[6/13] The solution can be found in the method described [here](https://discuss.pytorch.org/t/different-inference-time-for-the-same-model-trained-on-different-datasets/162687).\n\n\n\n\n\n\n\nDo loss functions or optimized model weights affect inference performance?\n\nI used these notebook ([train](https://www.kaggle.com/code/zijiangyang1116/birdclef-24-efficientnetb0-pytorch-train), [infer with ONNX](https://www.kaggle.com/code/zijiangyang1116/birdclef-24-inference-with-onnx)) for training and inference.  When I changed the loss function from nn.CrossEntropyLoss to nn.BCEWithLogitsLoss(), the inference time increased from 2s/batch to 10s/batch or more.  (Performance during TRAINING was not changed）\n\nIf you know the cause of the performance degradation and the countermeasure for it, please let me know.\n\n@zijiangyang1116  thank you for sharing very useful notebook!）"
  }
}