Linear Algebra for Machine Learning and Data Science Coursera, Module 3 Programming Assignment, Problem in Finding Solutions

Hello.

I’m trying to complete the programming assignment about linear transformations and neural networks in module 3 of the “Linear Algebra for Machine Learning and Data Science” course on Coursera. I’m having difficulty finding the solution for Exercise 2. Am I allowed to use the interactive linear transformation tool from the same module to help, or is that not allowed? What material are we allowed to use to solve this assignment? I’ve tested on paper, and I think I know what matrix we should use as the transformation matrix. I believe it’s [[m + (v[0] * v[-1]), 0], [0,1]]. So, we have to add the shearing factor (m) to the product of the first and last vector elements as the first element of the transformation matrix, with everything else being the same as the identity matrix. However, when I try it, it doesn’t pass the test. Also, for exercises 3 and 4, I was able to solve the problem by importing the math module in Python. However, will this affect the metadata and autograder? If so, what other option should I try?

Why would you need to import the math package? You already have numpy and it does everything that math does but even with vectors and matrices, right?

For Exercise 2, you need to construct a matrix T that implements the following linear transformation on the input vector v = (x, y)

T(v) = (x + my, y)

You’ll be implementing that operation as a dot product between the matrix you define and the vector v. So think about how dot product multiply works:

If A = [[a, b], [c, d]], then the result of A \cdot v will be:

(ax + by, cx + dy)

right?

So what to the values of a, b, c and d need to be to get the result we need?

I believe b is 0, c is 0, and d is 1. As for a, I believe it has to be the sum of the shearing factor (m) and the second element of the vector (v[1]). I tried this on paper, and it worked. However, it doesn’t work on the assignment, for some reason.

Never mind. I’ve figured it out.

2 Likes