{
  "id": 199361,
  "title": "My confuse about target_position",
  "url": "/competitions/lyft-motion-prediction-autonomous-vehicles/discussion/199361",
  "author_name": "",
  "post_date": "2020-11-25T12:56:22.622901100Z",
  "votes": 1,
  "comment_count": 3,
  "views": 0,
  "content": "<p>I saw someone convert target_positions from image-frame to word-frame but i didn't do that, so is that mean I should convert output of my model like this?</p>\n<p>e…..,I just found singel mode trajectory convert code in l5kit,  and I finished my multi-mode convert but LB is only 30.xxx but my local train/valid loss is 12.xxx, so I think there still is something wrong, my multi-mode convert code is here, I am looking forward to your help………🙌</p>",
  "messages": [
    {
      "id": "1090586",
      "postDate": "11/25/2020 12:56:22",
      "content": "<p>I saw someone convert target_positions from image-frame to word-frame but i didn't do that, so is that mean I should convert output of my model like this?</p>\n<p>e…..,I just found singel mode trajectory convert code in l5kit,  and I finished my multi-mode convert but LB is only 30.xxx but my local train/valid loss is 12.xxx, so I think there still is something wrong, my multi-mode convert code is here, I am looking forward to your help………🙌</p>",
      "rawMarkdown": "I saw someone convert target_positions from image-frame to word-frame but i didn't do that, so is that mean I should convert output of my model like this?\n\ne.....,I just found singel mode trajectory convert code in l5kit,  and I finished my multi-mode convert but LB is only 30.xxx but my local train/valid loss is 12.xxx, so I think there still is something wrong, my multi-mode convert code is here, I am looking forward to your help.........🙌",
      "votes": null
    },
    {
      "id": "1090589",
      "postDate": "11/25/2020 12:58:18",
      "content": "<p>Here is my code<br>\n`if cfg[\"model_params\"][\"predict\"]:</p>\n<pre><code>model.eval()\ntorch.set_grad_enabled(False)\n\n# store information for evaluation\nfuture_coords_offsets_pd = []\ntimestamps = []\nconfidences_list = []\nagent_ids = []\n\nprogress_bar = tqdm(test_dataloader)\n\nfor data in progress_bar:\n\n    preds, confidences = forward(data, model, device)\n\n    #fix for the new environment\n    preds = preds.cpu().numpy()\n    world_from_agents = data[\"world_from_agent\"].numpy()\n    centroids = data[\"centroid\"].numpy()\n    coords_offset = []\n\n    # convert into world coordinates and compute offsets\n    for idx in range(len(preds)):\n        for mode in range(3):\n            preds[idx, mode, :, :] = transform_points(preds[idx, mode, :, :], world_from_agents[idx]) - centroids[idx][:2]\n\n    future_coords_offsets_pd.append(preds.copy())\n    confidences_list.append(confidences.cpu().numpy().copy())\n    timestamps.append(data[\"timestamp\"].numpy().copy())\n    agent_ids.append(data[\"track_id\"].numpy().copy()) \n</code></pre>\n<p>pred_path = 'submission.csv'<br>\nwrite_pred_csv(<br>\n    pred_path,<br>\n    timestamps=np.concatenate(timestamps),<br>\n    track_ids=np.concatenate(agent_ids),<br>\n    coords=np.concatenate(future_coords_offsets_pd),<br>\n    confs=np.concatenate(confidences_list),<br>\n)<br>\ndf<br>\n`</p>",
      "rawMarkdown": "Here is my code\n`if cfg[\"model_params\"][\"predict\"]:\n    \n    model.eval()\n    torch.set_grad_enabled(False)\n\n    # store information for evaluation\n    future_coords_offsets_pd = []\n    timestamps = []\n    confidences_list = []\n    agent_ids = []\n\n    progress_bar = tqdm(test_dataloader)\n    \n    for data in progress_bar:\n        \n        preds, confidences = forward(data, model, device)\n    \n        #fix for the new environment\n        preds = preds.cpu().numpy()\n        world_from_agents = data[\"world_from_agent\"].numpy()\n        centroids = data[\"centroid\"].numpy()\n        coords_offset = []\n        \n        # convert into world coordinates and compute offsets\n        for idx in range(len(preds)):\n            for mode in range(3):\n                preds[idx, mode, :, :] = transform_points(preds[idx, mode, :, :], world_from_agents[idx]) - centroids[idx][:2]\n    \n        future_coords_offsets_pd.append(preds.copy())\n        confidences_list.append(confidences.cpu().numpy().copy())\n        timestamps.append(data[\"timestamp\"].numpy().copy())\n        agent_ids.append(data[\"track_id\"].numpy().copy()) \n\npred_path = 'submission.csv'\nwrite_pred_csv(\n    pred_path,\n    timestamps=np.concatenate(timestamps),\n    track_ids=np.concatenate(agent_ids),\n    coords=np.concatenate(future_coords_offsets_pd),\n    confs=np.concatenate(confidences_list),\n)\ndf\n`",
      "votes": null
    },
    {
      "id": "1091021",
      "postDate": "11/25/2020 18:21:26",
      "content": "<p>Your code for transformation looks correct to me. And it doesn't look like a conversion error.<br>\nIt is completely reasonable to see train score 12 but LB 30 if you overfit. <br>\nAlso, for the val loss are you using the chopped validation set? That should usually be very close (or slightly higher) to the LB.</p>",
      "rawMarkdown": "Your code for transformation looks correct to me. And it doesn't look like a conversion error.\nIt is completely reasonable to see train score 12 but LB 30 if you overfit. \nAlso, for the val loss are you using the chopped validation set? That should usually be very close (or slightly higher) to the LB.",
      "votes": null
    },
    {
      "id": "1091264",
      "postDate": "11/25/2020 22:36:46",
      "content": "<p>Yes, I used the chopped validation set and got valid score 12.xxx, but LB is terrible….</p>",
      "rawMarkdown": "Yes, I used the chopped validation set and got valid score 12.xxx, but LB is terrible....",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1090589,
      "author_name": "wangchris",
      "author_url": "",
      "post_date": "11/25/2020 12:58:18",
      "content": "<p>Here is my code<br>\n`if cfg[\"model_params\"][\"predict\"]:</p>\n<pre><code>model.eval()\ntorch.set_grad_enabled(False)\n\n# store information for evaluation\nfuture_coords_offsets_pd = []\ntimestamps = []\nconfidences_list = []\nagent_ids = []\n\nprogress_bar = tqdm(test_dataloader)\n\nfor data in progress_bar:\n\n    preds, confidences = forward(data, model, device)\n\n    #fix for the new environment\n    preds = preds.cpu().numpy()\n    world_from_agents = data[\"world_from_agent\"].numpy()\n    centroids = data[\"centroid\"].numpy()\n    coords_offset = []\n\n    # convert into world coordinates and compute offsets\n    for idx in range(len(preds)):\n        for mode in range(3):\n            preds[idx, mode, :, :] = transform_points(preds[idx, mode, :, :], world_from_agents[idx]) - centroids[idx][:2]\n\n    future_coords_offsets_pd.append(preds.copy())\n    confidences_list.append(confidences.cpu().numpy().copy())\n    timestamps.append(data[\"timestamp\"].numpy().copy())\n    agent_ids.append(data[\"track_id\"].numpy().copy()) \n</code></pre>\n<p>pred_path = 'submission.csv'<br>\nwrite_pred_csv(<br>\n    pred_path,<br>\n    timestamps=np.concatenate(timestamps),<br>\n    track_ids=np.concatenate(agent_ids),<br>\n    coords=np.concatenate(future_coords_offsets_pd),<br>\n    confs=np.concatenate(confidences_list),<br>\n)<br>\ndf<br>\n`</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1091021,
      "author_name": "louis925",
      "author_url": "",
      "post_date": "11/25/2020 18:21:26",
      "content": "<p>Your code for transformation looks correct to me. And it doesn't look like a conversion error.<br>\nIt is completely reasonable to see train score 12 but LB 30 if you overfit. <br>\nAlso, for the val loss are you using the chopped validation set? That should usually be very close (or slightly higher) to the LB.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1091264,
          "author_name": "wangchris",
          "author_url": "",
          "post_date": "11/25/2020 22:36:46",
          "content": "<p>Yes, I used the chopped validation set and got valid score 12.xxx, but LB is terrible….</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1090586": "I saw someone convert target_positions from image-frame to word-frame but i didn't do that, so is that mean I should convert output of my model like this?\n\ne.....,I just found singel mode trajectory convert code in l5kit,  and I finished my multi-mode convert but LB is only 30.xxx but my local train/valid loss is 12.xxx, so I think there still is something wrong, my multi-mode convert code is here, I am looking forward to your help.........🙌",
    "1090589": "Here is my code\n`if cfg[\"model_params\"][\"predict\"]:\n    \n    model.eval()\n    torch.set_grad_enabled(False)\n\n    # store information for evaluation\n    future_coords_offsets_pd = []\n    timestamps = []\n    confidences_list = []\n    agent_ids = []\n\n    progress_bar = tqdm(test_dataloader)\n    \n    for data in progress_bar:\n        \n        preds, confidences = forward(data, model, device)\n    \n        #fix for the new environment\n        preds = preds.cpu().numpy()\n        world_from_agents = data[\"world_from_agent\"].numpy()\n        centroids = data[\"centroid\"].numpy()\n        coords_offset = []\n        \n        # convert into world coordinates and compute offsets\n        for idx in range(len(preds)):\n            for mode in range(3):\n                preds[idx, mode, :, :] = transform_points(preds[idx, mode, :, :], world_from_agents[idx]) - centroids[idx][:2]\n    \n        future_coords_offsets_pd.append(preds.copy())\n        confidences_list.append(confidences.cpu().numpy().copy())\n        timestamps.append(data[\"timestamp\"].numpy().copy())\n        agent_ids.append(data[\"track_id\"].numpy().copy()) \n\npred_path = 'submission.csv'\nwrite_pred_csv(\n    pred_path,\n    timestamps=np.concatenate(timestamps),\n    track_ids=np.concatenate(agent_ids),\n    coords=np.concatenate(future_coords_offsets_pd),\n    confs=np.concatenate(confidences_list),\n)\ndf\n`",
    "1091021": "Your code for transformation looks correct to me. And it doesn't look like a conversion error.\nIt is completely reasonable to see train score 12 but LB 30 if you overfit. \nAlso, for the val loss are you using the chopped validation set? That should usually be very close (or slightly higher) to the LB.",
    "1091264": "Yes, I used the chopped validation set and got valid score 12.xxx, but LB is terrible...."
  },
  "source": "meta"
}