{
  "id": 455672,
  "title": "RMSE > MSE",
  "url": "/competitions/predict-ai-model-runtime/discussion/455672",
  "author_name": "Louka Ewington-Pitsos",
  "post_date": "2023-11-15T22:59:43.482000",
  "votes": 7,
  "comment_count": 0,
  "views": 0,
  "content": "<p>When running experiments I kept noticing these huge spikes in the loss for certain graphs. </p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1577010%2Fdff36be694a715752d6dcfe6ba4f8f03%2FScreenshot%20from%202023-11-16%2009-55-23.png?generation=1700088937258402&amp;alt=media\" alt=\"ouch\"></p>\n<p>Turned out this was being caused by the MSE component of the loss. Seemed like this is probably not good for the model. </p>\n<p>I ran two experiments with the provided codebase: <a href=\"https://github.com/google-research-datasets/tpu_graphs\" target=\"_blank\">https://github.com/google-research-datasets/tpu_graphs</a> </p>\n<p>RMSE</p>\n<p><code>python tiles_train.py --model=EarlyJoinSAGE --epochs=5 --losses='ListMLELoss:1,RMSE:0.02'</code></p>\n<p>vs MSE</p>\n<p><code>python tiles_train.py --model=EarlyJoinSAGE --epochs=5 --losses='ListMLELoss:1,MSE:0.02'</code></p>\n<p>with <code>metrics.py</code> altered to add RMSE as </p>\n<pre><code>def root:\n    return tf.sqrt(tf.reduce))\n\nLOSS_DICT = {\n    'ListMLELoss': tfr.keras.losses.,\n    'PairwiseHingeLoss': tfr.keras.losses.,\n    'MSE': tf.keras.losses.,\n    'RMSE': root_mean_squared_error\n}\n</code></pre>\n<p>RMSE seems to increase the <code>opa_metric</code> and <code>val_opa_metric</code> significantly (and of course the loss goes down in both cases because the MSE component is now smaller)</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1577010%2Ff0100655072ce8611c8f73eb3ab5fd6f%2FScreenshot%20from%202023-11-16%2010-00-53.png?generation=1700089284457313&amp;alt=media\" alt=\"noice\"></p>\n<p>maybe this is helpful to someone :D</p>",
  "messages": [
    {
      "id": 2526561,
      "postDate": "2023-11-15T22:59:43.483Z",
      "content": "<p>When running experiments I kept noticing these huge spikes in the loss for certain graphs. </p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1577010%2Fdff36be694a715752d6dcfe6ba4f8f03%2FScreenshot%20from%202023-11-16%2009-55-23.png?generation=1700088937258402&amp;alt=media\" alt=\"ouch\"></p>\n<p>Turned out this was being caused by the MSE component of the loss. Seemed like this is probably not good for the model. </p>\n<p>I ran two experiments with the provided codebase: <a href=\"https://github.com/google-research-datasets/tpu_graphs\" target=\"_blank\">https://github.com/google-research-datasets/tpu_graphs</a> </p>\n<p>RMSE</p>\n<p><code>python tiles_train.py --model=EarlyJoinSAGE --epochs=5 --losses='ListMLELoss:1,RMSE:0.02'</code></p>\n<p>vs MSE</p>\n<p><code>python tiles_train.py --model=EarlyJoinSAGE --epochs=5 --losses='ListMLELoss:1,MSE:0.02'</code></p>\n<p>with <code>metrics.py</code> altered to add RMSE as </p>\n<pre><code>def root:\n    return tf.sqrt(tf.reduce))\n\nLOSS_DICT = {\n    'ListMLELoss': tfr.keras.losses.,\n    'PairwiseHingeLoss': tfr.keras.losses.,\n    'MSE': tf.keras.losses.,\n    'RMSE': root_mean_squared_error\n}\n</code></pre>\n<p>RMSE seems to increase the <code>opa_metric</code> and <code>val_opa_metric</code> significantly (and of course the loss goes down in both cases because the MSE component is now smaller)</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1577010%2Ff0100655072ce8611c8f73eb3ab5fd6f%2FScreenshot%20from%202023-11-16%2010-00-53.png?generation=1700089284457313&amp;alt=media\" alt=\"noice\"></p>\n<p>maybe this is helpful to someone :D</p>",
      "rawMarkdown": "When running experiments I kept noticing these huge spikes in the loss for certain graphs. \n\n![ouch](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1577010%2Fdff36be694a715752d6dcfe6ba4f8f03%2FScreenshot%20from%202023-11-16%2009-55-23.png?generation=1700088937258402&alt=media)\n\nTurned out this was being caused by the MSE component of the loss. Seemed like this is probably not good for the model. \n\nI ran two experiments with the provided codebase: https://github.com/google-research-datasets/tpu_graphs \n\nRMSE\n\n`python tiles_train.py --model=EarlyJoinSAGE --epochs=5 --losses='ListMLELoss:1,RMSE:0.02'`\n\nvs MSE\n\n`python tiles_train.py --model=EarlyJoinSAGE --epochs=5 --losses='ListMLELoss:1,MSE:0.02'`\n\nwith `metrics.py` altered to add RMSE as \n\n```\ndef root_mean_squared_error(y_true, y_pred):\n    return tf.sqrt(tf.reduce_mean(tf.square(y_pred - y_true)))\n\nLOSS_DICT = {\n    'ListMLELoss': tfr.keras.losses.ListMLELoss(temperature=10),\n    'PairwiseHingeLoss': tfr.keras.losses.PairwiseHingeLoss(temperature=10),\n    'MSE': tf.keras.losses.MeanSquaredError(),\n    'RMSE': root_mean_squared_error\n}\n```\n\nRMSE seems to increase the `opa_metric` and `val_opa_metric` significantly (and of course the loss goes down in both cases because the MSE component is now smaller)\n\n![noice](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1577010%2Ff0100655072ce8611c8f73eb3ab5fd6f%2FScreenshot%20from%202023-11-16%2010-00-53.png?generation=1700089284457313&alt=media)\n\nmaybe this is helpful to someone :D",
      "votes": 6
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "2526561": "When running experiments I kept noticing these huge spikes in the loss for certain graphs. \n\n![ouch](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1577010%2Fdff36be694a715752d6dcfe6ba4f8f03%2FScreenshot%20from%202023-11-16%2009-55-23.png?generation=1700088937258402&alt=media)\n\nTurned out this was being caused by the MSE component of the loss. Seemed like this is probably not good for the model. \n\nI ran two experiments with the provided codebase: https://github.com/google-research-datasets/tpu_graphs \n\nRMSE\n\n`python tiles_train.py --model=EarlyJoinSAGE --epochs=5 --losses='ListMLELoss:1,RMSE:0.02'`\n\nvs MSE\n\n`python tiles_train.py --model=EarlyJoinSAGE --epochs=5 --losses='ListMLELoss:1,MSE:0.02'`\n\nwith `metrics.py` altered to add RMSE as \n\n```\ndef root_mean_squared_error(y_true, y_pred):\n    return tf.sqrt(tf.reduce_mean(tf.square(y_pred - y_true)))\n\nLOSS_DICT = {\n    'ListMLELoss': tfr.keras.losses.ListMLELoss(temperature=10),\n    'PairwiseHingeLoss': tfr.keras.losses.PairwiseHingeLoss(temperature=10),\n    'MSE': tf.keras.losses.MeanSquaredError(),\n    'RMSE': root_mean_squared_error\n}\n```\n\nRMSE seems to increase the `opa_metric` and `val_opa_metric` significantly (and of course the loss goes down in both cases because the MSE component is now smaller)\n\n![noice](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1577010%2Ff0100655072ce8611c8f73eb3ab5fd6f%2FScreenshot%20from%202023-11-16%2010-00-53.png?generation=1700089284457313&alt=media)\n\nmaybe this is helpful to someone :D"
  }
}