{
  "id": 310450,
  "title": "Get Nan value from predict when I reduce the bs and lr.",
  "url": "/competitions/happy-whale-and-dolphin/discussion/310450",
  "author_name": "",
  "post_date": "2022-03-01T12:17:07.725765600Z",
  "votes": 6,
  "comment_count": 5,
  "views": 0,
  "content": "<p>I use this notebook<a href=\"url\" target=\"_blank\">https://www.kaggle.com/dragonzhang/happywhale-effnet-b7-fork-with-detic-crop</a>. And when use model to get the embeddings of test data. There is the error that get Nan value from predict. </p>\n<blockquote>\n  <p>Input contains NaN, infinity or a value too large for dtype('float32').</p>\n</blockquote>\n<p>I'd like to ask if anyone is in the same situation as me and how to solve it. Thx</p>",
  "messages": [
    {
      "id": "1708385",
      "postDate": "03/01/2022 12:17:07",
      "content": "<p>I use this notebook<a href=\"url\" target=\"_blank\">https://www.kaggle.com/dragonzhang/happywhale-effnet-b7-fork-with-detic-crop</a>. And when use model to get the embeddings of test data. There is the error that get Nan value from predict. </p>\n<blockquote>\n  <p>Input contains NaN, infinity or a value too large for dtype('float32').</p>\n</blockquote>\n<p>I'd like to ask if anyone is in the same situation as me and how to solve it. Thx</p>",
      "rawMarkdown": "I use this notebook[https://www.kaggle.com/dragonzhang/happywhale-effnet-b7-fork-with-detic-crop](url). And when use model to get the embeddings of test data. There is the error that get Nan value from predict. \n> Input contains NaN, infinity or a value too large for dtype('float32').\n\nI'd like to ask if anyone is in the same situation as me and how to solve it. Thx",
      "votes": null
    },
    {
      "id": "1708492",
      "postDate": "03/01/2022 13:43:30",
      "content": "<p>It is very complicated to give answer, because there are a lot of potential reasons, and not enough information. But I have similar problem when I have zero embedding, in normalize step we divide to vector norm, vector norm of zero vector is zero and we have NaN when divide to zero</p>",
      "rawMarkdown": "It is very complicated to give answer, because there are a lot of potential reasons, and not enough information. But I have similar problem when I have zero embedding, in normalize step we divide to vector norm, vector norm of zero vector is zero and we have NaN when divide to zero",
      "votes": null
    },
    {
      "id": "1709091",
      "postDate": "03/02/2022 00:33:06",
      "content": "<p>So maybe I can make all nan values to zero?</p>",
      "rawMarkdown": "So maybe I can make all nan values to zero?",
      "votes": null
    },
    {
      "id": "1709092",
      "postDate": "03/02/2022 00:34:15",
      "content": "<p>I have encountered the same problem, not only in this notebook, but also sometimes when changing the model, which I haven't solved yet and look forward to help</p>",
      "rawMarkdown": "I have encountered the same problem, not only in this notebook, but also sometimes when changing the model, which I haven't solved yet and look forward to help",
      "votes": null
    },
    {
      "id": "1709450",
      "postDate": "03/02/2022 07:57:14",
      "content": "<p>I also faced the same error when modeling a regression model in other data. The problem was that there was Nan values and models don't accept Nan values and give errors. I suggest you to try replacing the Nan values to 0 (if field/feature/column is numerical) or 'NA' (if feature/field/column is categorical) because this solved the (same) error that you are facing. Maybe it will solve yours too. Upvote if it helps!</p>\n<p>To find nan values you can use<br>\n<code>df[df.isna().any(axis=1)]</code></p>",
      "rawMarkdown": "I also faced the same error when modeling a regression model in other data. The problem was that there was Nan values and models don't accept Nan values and give errors. I suggest you to try replacing the Nan values to 0 (if field/feature/column is numerical) or 'NA' (if feature/field/column is categorical) because this solved the (same) error that you are facing. Maybe it will solve yours too. Upvote if it helps!\n\nTo find nan values you can use\n```df[df.isna().any(axis=1)]```",
      "votes": null
    },
    {
      "id": "1709742",
      "postDate": "03/02/2022 13:03:49",
      "content": "<p>One solution is yes, second you could add i.e 1e-9 to all values</p>",
      "rawMarkdown": "One solution is yes, second you could add i.e 1e-9 to all values",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1708492,
      "author_name": "kwentar",
      "author_url": "",
      "post_date": "03/01/2022 13:43:30",
      "content": "<p>It is very complicated to give answer, because there are a lot of potential reasons, and not enough information. But I have similar problem when I have zero embedding, in normalize step we divide to vector norm, vector norm of zero vector is zero and we have NaN when divide to zero</p>",
      "votes": null,
      "replies": [
        {
          "id": 1709091,
          "author_name": "shawntung",
          "author_url": "",
          "post_date": "03/02/2022 00:33:06",
          "content": "<p>So maybe I can make all nan values to zero?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1709742,
          "author_name": "kwentar",
          "author_url": "",
          "post_date": "03/02/2022 13:03:49",
          "content": "<p>One solution is yes, second you could add i.e 1e-9 to all values</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1709092,
      "author_name": "mrhagchwh",
      "author_url": "",
      "post_date": "03/02/2022 00:34:15",
      "content": "<p>I have encountered the same problem, not only in this notebook, but also sometimes when changing the model, which I haven't solved yet and look forward to help</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1709450,
      "author_name": "devangvinci",
      "author_url": "",
      "post_date": "03/02/2022 07:57:14",
      "content": "<p>I also faced the same error when modeling a regression model in other data. The problem was that there was Nan values and models don't accept Nan values and give errors. I suggest you to try replacing the Nan values to 0 (if field/feature/column is numerical) or 'NA' (if feature/field/column is categorical) because this solved the (same) error that you are facing. Maybe it will solve yours too. Upvote if it helps!</p>\n<p>To find nan values you can use<br>\n<code>df[df.isna().any(axis=1)]</code></p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1708385": "I use this notebook[https://www.kaggle.com/dragonzhang/happywhale-effnet-b7-fork-with-detic-crop](url). And when use model to get the embeddings of test data. There is the error that get Nan value from predict. \n> Input contains NaN, infinity or a value too large for dtype('float32').\n\nI'd like to ask if anyone is in the same situation as me and how to solve it. Thx",
    "1708492": "It is very complicated to give answer, because there are a lot of potential reasons, and not enough information. But I have similar problem when I have zero embedding, in normalize step we divide to vector norm, vector norm of zero vector is zero and we have NaN when divide to zero",
    "1709091": "So maybe I can make all nan values to zero?",
    "1709092": "I have encountered the same problem, not only in this notebook, but also sometimes when changing the model, which I haven't solved yet and look forward to help",
    "1709450": "I also faced the same error when modeling a regression model in other data. The problem was that there was Nan values and models don't accept Nan values and give errors. I suggest you to try replacing the Nan values to 0 (if field/feature/column is numerical) or 'NA' (if feature/field/column is categorical) because this solved the (same) error that you are facing. Maybe it will solve yours too. Upvote if it helps!\n\nTo find nan values you can use\n```df[df.isna().any(axis=1)]```",
    "1709742": "One solution is yes, second you could add i.e 1e-9 to all values"
  },
  "source": "meta"
}