{"record":{"id":"c27c0cc104d751c4","repo":"rohitg00/ai-engineering-from-scratch","slug":"cannot-multiply-shapes-self-shape-and-other-sha","errorCode":null,"errorMessage":"Cannot multiply shapes {self.shape} and {other.shape}: inner dimensions {self.cols} != {other.rows}","messagePattern":"Cannot multiply shapes (.+?) and (.+?): inner dimensions (.+?) != (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phases/01-math-foundations/02-vectors-matrices-operations/code/matrices.py","lineNumber":94,"sourceCode":"            [self.data[i][j] - other.data[i][j] for j in range(self.cols)]\n            for i in range(self.rows)\n        ])\n\n    def scalar_multiply(self, scalar):\n        return Matrix([\n            [self.data[i][j] * scalar for j in range(self.cols)]\n            for i in range(self.rows)\n        ])\n\n    def element_wise_multiply(self, other):\n        return Matrix([\n            [self.data[i][j] * other.data[i][j] for j in range(self.cols)]\n            for i in range(self.rows)\n        ])\n\n    def matmul(self, other):\n        if self.cols != other.rows:\n            raise ValueError(\n                f\"Cannot multiply shapes {self.shape} and {other.shape}: \"\n                f\"inner dimensions {self.cols} != {other.rows}\"\n            )\n        return Matrix([\n            [\n                sum(self.data[i][k] * other.data[k][j] for k in range(self.cols))\n                for j in range(other.cols)\n            ]\n            for i in range(self.rows)\n        ])\n\n    def __matmul__(self, other):\n        return self.matmul(other)\n\n    def transpose(self):\n        return Matrix([\n            [self.data[j][i] for j in range(self.rows)]\n            for i in range(self.cols)","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/01-math-foundations/02-vectors-matrices-operations/code/matrices.py#L76-L112","documentation":"Error \"Cannot multiply shapes {self.shape} and {other.shape}: inner dimensions {self.cols} != {other.rows}\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/01-math-foundations/02-vectors-matrices-operations/code/matrices.py:94 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}