C1W2 Gaussian Elimination Exercise 3

Can anyone offer some advice. In exercise 3 I am getting the following message: An exception was thrown while running your function: ‘numpy.int64’ object is not iterable.
Input matrix:
[[1 0 0 5]
[0 1 0 6]
[0 0 1 7]]

1 Like

Welcome to the forum!

In the future, please don’t share your notebook or your code on the forum. That’s not allowed by the Code of Conduct.

It’s not a problem, I can remove the link from your post.

Stand by for some tips about your issue.

Apologies I’ve removed it

1 Like

OK.
There are a lot of issues in your code for back_substitution() - most of the for-loops are using the wrong ranges, and then you’re using index and value incorrectly.

However, this assignment is being re-written, because it’s too complicated for the educational value it provides.

Please read this thread, and you can decide how you want to proceed.

1 Like

Ok thanks, I’d like to try and figure it out. In terms of the range of the loops why is using i in range (num_rows,-1,-1) and j in range (i-1,-1,-1) wrong ?

1 Like

There are a lot of ways to write the for-loop ranges. These impact how you write the rest of the code, and any time you start manipulating vector indices individually, there’s a big chance for mistakes that are hard to debug.

The ranges that the assignment authors used seem to make the rest of the code simpler.

Tips:

At 1, use “num_rows”
At 2, use “i+1, num_rows”
With this, the only calculated index values you’ll need are:

  • num_rows-1-i
  • num_rows-1-j

Update for the new version of this notebook: You may need to substitute the variable “row” for either i or j.

1 Like

Thanks you, but does that method actually iterate from the bottom up ? In my understanding that would start at 0 and work down to the bottom row

1 Like

It does, by subtracting i or j from num_rows.

Cool thanks, and for the index value that is obtained through the earlier defined function ?

1 Like

‘index’ is returned by the function that has “get_index…()” in the function name.

Please do not post your code on the forum. That isn’t allowed by the Code of Conduct.

If a mentor needs to see your code, we’ll contact you with instructions.

Two notes (only because this assignment is being replaced soon):

  • For “index = …”: ‘j’ is not the correct index to use.
  • For "row_to_reduce = ‘’': Don’t index ‘M’ there. You already computed the “substitution row” earlier.
1 Like

got it…replaced j with the index of substitution row…thanks…!

2 Likes

I was about to reply, when your message disappeared.

1 Like

I managed to get all tests passed but I received 0%

1 Like

What is the detailed feedback from the grader?

Passing the tests in the notebook does not prove your code is perfect.

Also, if you ran the notebook locally and then uploaded it back to Coursera for grading, this usually mangles the metadata that the grader uses. And then it gets unhappy and throws mysterious error messages.

There was a problem compiling the code from your notebook. Details:
cannot assign to None (, line 329)

this was for each section

No errors are being throw up in any section of the notebook

1 Like

Typically this means you have damaged metadata inside the notebook.
Did you work on it locally and then upload it back to Coursera for grading?

1 Like

Some work was done locally and then uploaded to coursera yes

1 Like

Check your personal messages for instructions (in a few minutes).

I got same msg: There was a problem compiling the code from your notebook. Details: cannot assign to None (, line 347)

Programming Assignment: Gaussian Elimination

1 Like