{
  "id": 455344,
  "title": "RuntimeError: mat1 and mat2 shapes cannot be multiplied",
  "url": "/competitions/stanford-ribonanza-rna-folding/discussion/455344",
  "author_name": "",
  "post_date": "2023-11-14T10:07:30.616558200Z",
  "votes": null,
  "comment_count": 2,
  "views": 0,
  "content": "<p>RuntimeError: mat1 and mat2 shapes cannot be multiplied (45312x960 and 1536x2)</p>\n<p>Has anyone else ran into a similar error, I tried using a different model architecture in this <a href=\"url\" target=\"_blank\">https://www.kaggle.com/code/iafoss/rna-starter-0-186-lb</a> and it happens in this line.</p>\n<p>self.proj_out = nn.Linear(dim,2)</p>\n<p>(I just need ideas on fixing it, since revealing the error would also reveal the architecture)</p>\n<p>Thanks in advance🙏</p>",
  "messages": [
    {
      "id": "2524522",
      "postDate": "11/14/2023 10:07:30",
      "content": "<p>RuntimeError: mat1 and mat2 shapes cannot be multiplied (45312x960 and 1536x2)</p>\n<p>Has anyone else ran into a similar error, I tried using a different model architecture in this <a href=\"url\" target=\"_blank\">https://www.kaggle.com/code/iafoss/rna-starter-0-186-lb</a> and it happens in this line.</p>\n<p>self.proj_out = nn.Linear(dim,2)</p>\n<p>(I just need ideas on fixing it, since revealing the error would also reveal the architecture)</p>\n<p>Thanks in advance🙏</p>",
      "rawMarkdown": "RuntimeError: mat1 and mat2 shapes cannot be multiplied (45312x960 and 1536x2)\n\nHas anyone else ran into a similar error, I tried using a different model architecture in this [https://www.kaggle.com/code/iafoss/rna-starter-0-186-lb](url) and it happens in this line.\n\nself.proj_out = nn.Linear(dim,2)\n\n(I just need ideas on fixing it, since revealing the error would also reveal the architecture)\n\nThanks in advance🙏",
      "votes": null
    },
    {
      "id": "2524674",
      "postDate": "11/14/2023 12:57:17",
      "content": "<p>The problem is easy to find, it is basic linear algebra. To multiply two matrices, they must be of shape (m,n) and (n,p). The output will be a (m,p) matrix.</p>\n<p>Here's a few valid multiplications:</p>\n<p>(2,3) x (3,4) -&gt; (2,4)</p>\n<p>(1,2) x (2,5) -&gt; (1,5)</p>\n<p>(45312,960) x (960,2) -&gt; (45312, 2)</p>\n<p>Machine learning is heavily based on mathematics. While on appearance learning how to use python, sklearn, and a deep-learning framework seems to do the trick, not knowing the theory will lead to many garbage models.</p>\n<p>The following math subject are helpful for data science, machine learning, and deep learning:</p>\n<p>Numerical Method for engineers: Teach about linear regression, curve fitting, error metrics, etc.</p>\n<p>Linear Algebra: The most important subject</p>\n<p>Calculus and Differential Equations</p>",
      "rawMarkdown": "The problem is easy to find, it is basic linear algebra. To multiply two matrices, they must be of shape (m,n) and (n,p). The output will be a (m,p) matrix.\n\nHere's a few valid multiplications:\n\n(2,3) x (3,4) -> (2,4)\n\n(1,2) x (2,5) -> (1,5)\n\n(45312,960) x (960,2) -> (45312, 2)\n\nMachine learning is heavily based on mathematics. While on appearance learning how to use python, sklearn, and a deep-learning framework seems to do the trick, not knowing the theory will lead to many garbage models.\n\nThe following math subject are helpful for data science, machine learning, and deep learning:\n\nNumerical Method for engineers: Teach about linear regression, curve fitting, error metrics, etc.\n\nLinear Algebra: The most important subject\n\nCalculus and Differential Equations",
      "votes": null
    },
    {
      "id": "2545962",
      "postDate": "12/02/2023 01:22:40",
      "content": "<p>This typically happens when you mix up your dim and your dim_feedfoward, or more generally when you have wrongly initialized some successive nn modules. Check that the output dimension of your previous module is dim, which is the input dimension of your nn.Linear here. </p>",
      "rawMarkdown": "This typically happens when you mix up your dim and your dim_feedfoward, or more generally when you have wrongly initialized some successive nn modules. Check that the output dimension of your previous module is dim, which is the input dimension of your nn.Linear here.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2524674,
      "author_name": "alexandrepetit881234",
      "author_url": "",
      "post_date": "11/14/2023 12:57:17",
      "content": "<p>The problem is easy to find, it is basic linear algebra. To multiply two matrices, they must be of shape (m,n) and (n,p). The output will be a (m,p) matrix.</p>\n<p>Here's a few valid multiplications:</p>\n<p>(2,3) x (3,4) -&gt; (2,4)</p>\n<p>(1,2) x (2,5) -&gt; (1,5)</p>\n<p>(45312,960) x (960,2) -&gt; (45312, 2)</p>\n<p>Machine learning is heavily based on mathematics. While on appearance learning how to use python, sklearn, and a deep-learning framework seems to do the trick, not knowing the theory will lead to many garbage models.</p>\n<p>The following math subject are helpful for data science, machine learning, and deep learning:</p>\n<p>Numerical Method for engineers: Teach about linear regression, curve fitting, error metrics, etc.</p>\n<p>Linear Algebra: The most important subject</p>\n<p>Calculus and Differential Equations</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 2545962,
      "author_name": "kkameleon",
      "author_url": "",
      "post_date": "12/02/2023 01:22:40",
      "content": "<p>This typically happens when you mix up your dim and your dim_feedfoward, or more generally when you have wrongly initialized some successive nn modules. Check that the output dimension of your previous module is dim, which is the input dimension of your nn.Linear here. </p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2524522": "RuntimeError: mat1 and mat2 shapes cannot be multiplied (45312x960 and 1536x2)\n\nHas anyone else ran into a similar error, I tried using a different model architecture in this [https://www.kaggle.com/code/iafoss/rna-starter-0-186-lb](url) and it happens in this line.\n\nself.proj_out = nn.Linear(dim,2)\n\n(I just need ideas on fixing it, since revealing the error would also reveal the architecture)\n\nThanks in advance🙏",
    "2524674": "The problem is easy to find, it is basic linear algebra. To multiply two matrices, they must be of shape (m,n) and (n,p). The output will be a (m,p) matrix.\n\nHere's a few valid multiplications:\n\n(2,3) x (3,4) -> (2,4)\n\n(1,2) x (2,5) -> (1,5)\n\n(45312,960) x (960,2) -> (45312, 2)\n\nMachine learning is heavily based on mathematics. While on appearance learning how to use python, sklearn, and a deep-learning framework seems to do the trick, not knowing the theory will lead to many garbage models.\n\nThe following math subject are helpful for data science, machine learning, and deep learning:\n\nNumerical Method for engineers: Teach about linear regression, curve fitting, error metrics, etc.\n\nLinear Algebra: The most important subject\n\nCalculus and Differential Equations",
    "2545962": "This typically happens when you mix up your dim and your dim_feedfoward, or more generally when you have wrongly initialized some successive nn modules. Check that the output dimension of your previous module is dim, which is the input dimension of your nn.Linear here."
  },
  "source": "meta"
}