C1W2 Gaussian Elimination - Need help - immediately lost

Please help me. I am absolutely and utterly stuck and lost just a few lines into the first programming assignment.

I can

# Transform matrices A and B into the augmented matrix M
M = np.hstack((A,B))

But what in world are they asking me to do with:
# Iterate over the rows.

For i, val in enumerate(M) ?

I am so lost…is anyone willing to hop on a Zoom call with me get me going by any chance?

Link to notebook

1 Like

For the creation of the augmented matrix, we already wrote a function to do that, right? If you want, you can write the same code again, but they intended that you call the function to do that.

What we are doing here is looping over the rows, right? So you can just use a simple for loop like:

for idx in range(num_rows):

Note that they gave you the variable num_rows in the template code. They used the len(A) to compute that, but my preference would be to write it this way:

num_rows = A.shape[0]

2 Likes

Echo the above… Setting it up as a function as well difficult to troubleshoot what’s going wrong. Great if there can be a bit more guidance on what exactly needs to be done here.

1 Like

The guidance is all the very detailed instructions above about how Gaussian Elimination works. Then you need to translate those instructions in python/numpy code to accomplish that. They try to give you hints in the comments in the template code to point you in the right direction.

But note that you already need to know python before you start here …

1 Like

This is probably the root of the problem. I do not know any python. Guess I thought I would pick that up from the assignments. Is there another resource I can use?

1 Like

Not super helpful. Don’t think not knowing python is the issue - can pick up programming language with a bit of trial and error but the decision to set up the first exercise as a compound function where getting 100% correct is needed is a bit puzzling. It’s a shame as I liked the course and curriculum otherwise but slightly confused on how to progress…

2 Likes

How much programming experience to you have in other languages? If you have solid experience in some other procedural language like JavaScript, C#, Java or C++, then you can just spend some time reading tutorials on the python.org website.

But if this is literally your first exposure to any kind of programming, then you should really find an “intro to python” course and take it. There are quite a few on Coursera.

1 Like

It’s pretty much my first intro to programming of any kind.

I do echo the sentiment that it seems like a lot of steps are combined into a single problem, but I am a total newbie hence it feels overwhelming.

Appreciate the guidance though, especially over the weekend.

1 Like

Sorry, I’m not sure what you are saying here. I hope it’s not that you’re used to programming in cases where things don’t need to be 100% correct. :scream_cat:

But the idea of structuring your code for modularity with layers of functions is just normal programming practice, right? You build the lower level functions first and then write the higher level logic that invokes them to solve the actual problem.

1 Like

You’re not solving for a specific matrix but rather setting up a function that works for all matrices, and where it isn’t really possible to step through and see where the function doesn’t work.

I’ve been trying to do that in parallel with an entirely different bit of code but again the commented guidance is a bit cryptic and I would actually probably set up a reduced row echelon algorithm quite differently so solving it within the construct you’ve laid out is a bit counterintuitive for me.

Anyways, I guess this isn’t something there is a solution for in which case I can move on but just wanted to check beforehand…

2 Likes

The people who answer questions here on the forums are not doing this as a 9 to 5 job. We are volunteers and we don’t get paid to do this. Meaning that we also don’t have “work hours”. Of course online sites like this are literally used by people all over the world in essentially every time zone.

2 Likes

Thank you :slight_smile: Sorry a bit frustrated as I’ve spent quite a few hours on this and don’t think of myself as an entire newbie to coding or linear algebra, although I do neither regularly. Appreciate your help.

1 Like

Yes, we are writing general code here, but it’s a perfectly valid debugging strategy to print intermediate results in the function code and then try it with some specific inputs to check the functionality. I frequently do exactly that. In this case, you can work it yourself by hand first with pen and paper, so that you know how it should “play out”.

1 Like

Any chance you can show me an example of what you mean by that?

Thanks again for everything Paul! I am just over in Santa Clara, so I owe you a coffee for sure!

1 Like

@AI_Learner_448, I recommend you look through YouTube’s library of Python tutorials, and work through one of them.

You can’t both learn about programming and Python specifically and take a math course that uses Python all at the same time. It’s too big a nut to crack.

Some of DLAI’s courses (specifically the ones taught by Andrew Ng) have quite gentle introductions to Python programming. The “Math for Machine Learning” course has a different instructor, and the level of tutorial-ism is much lower.

2 Likes

There are sort of two major approaches to debugging: you can use an actual interactive debugger and set breakpoints and display values. But that requires that you have a good debugging tool. I think there are great python environments that support that, but it’s not so clear that would work in the Jupyter notebook environment.

The “old school” approach is to “instrument” your code with print statement at various points. E.g. anytime there’s an “if/else”, put a print statement in each branch so that you can see how your logic is working. In our case here, print the row numbers and column numbers as you iterate and so forth. Of course that can generate a lot of output. But the joy of this approach is that it’s completely dynamic: you tune it as you go.

1 Like

I appreciate the guidance. I am a mid 30’s product manager who is interested in making the switch to working on more AI based products. I feel like understanding the math is probably more important to me than being able to program, but it wouldn’t hurt to have at least a little familiarity. I will look at some intro python courses. Thanks!

2 Likes

No helpful advice, just SAME. Also have no prior exposure to Python :confused: This course went from 0 to 60 real quick w this assignment. The speaker breaks the math concepts down like he’s talking to a kindergartener but I’m the kindergartener who just got pushed off a cliff w this python assignment!

1 Like

I recommend you attend a Python tutorial before you proceed any farther in this course.

Also not any help, only here to commiserate. Pretty disappointed that my progress in this class has come to a screeching halt because I don’t even know where to begin with this assignment. Admittedly I have minimal experience with Python but was not under the impression that was a prerequisite for this course.

I understand that we can use the augmented_matrix function that we defined earlier in the workbook, but the next line loses me. Sigh, will keep searching…