Mistakes Can't find

There was an error grading your submission. Details:
operands could not be broadcast together with shapes (4,) (3,)

{moderator edit - solution code removed}

What is the mistake here?

1 Like

Which course are you attending? You posted in a general discussion area.

Also, please do not post your code. That breaks the Code of Conduct.

I’m guessing this is the Gaussian Elimination assignment in M4ML C1 W2, but as Tom says it would be a good idea to post course related questions in the appropriate topic. That way you have a better chance that people who know that course will notice your questions. I used the little “edit pencil” on the title to move it to M4ML.

In that code think about what that first line using argmax will do. That will give you the highest index value in the given input line which has a non-zero element. Meaning the last one. If you think about what the goal is here, the last non-zero element has nothing to do with the goal, right? We already wrote some “helper” functions earlier that will give you what you need here.

The key point is that you need to have a clear picture of what the steps are here that your code needs to implement. I recommend taking one of the test cases and literally writing out all the steps with pencil and paper to make sure you are clear on what needs to happen. There’s no hope of getting the code correct if you don’t start with the correct goal clearly in mind.

1 Like

First of all, Sorry for posting the code, I never used this community before, hence wasn’t familiar with the norms.

Second of all, I corrected the programming, it ran but the elements of my matrices are coming of lower value than expected. Though in assignments, I was never told to deal with matrix elements, I just did the programming part.

1 Like

No harm done on the source code: I just edited the post to hide the code.

I’m not sure I understand your point about not dealing with matrix elements. Everything we are doing here is manipulating matrices, but exactly how we do the operations depends on what we are doing at a given point. Here we are operating on the rows and handling them one row at a time. Of course a row is a vector and we can operate on it as such: e.g. multiplying all the elements by a scaling factor and then subtracting that from the original row vector to get a new vector.

One thing you could do would be to show us the output you get when you run the failing test. That may not be enough for us to figure out what is wrong, but it’s a start.

1 Like