Using Linear Algebra instead of loops

Anybody else challenging themselves to try to solve a lot of these problems through linear algebra using numpy instead of loops? For example, on the Recommender Systems lab I came across, which allowed me to mask the irrelevant values in the cost function.

Well here was the next subsection in that lab:

It is important to create a vectorized implementation to compute 𝐽 , since it will later be called many times during optimization. The linear algebra utilized is not the focus of this series, so the implementation is provided. If you are an expert in linear algebra, feel free to create your version without referencing the code below.

Guess I have my own version to compare it with :slight_smile:

You are free to implement the code in any way you wish. The grader only checks your return values, not your method.

For-loops are not efficient, so it’s good to explore other methods.