I’m having a hard time understanding what is being asked in Q1.3 & 1.4 of homework 1:
Compute 𝐶=𝐴𝐵, treating 𝐴 as a matrix but computing the result for each column of 𝐵 one at a time.
Compute 𝐶=𝐴𝐵, treating 𝐴 and 𝐵 as collections of vectors.
How do we “treat A as a matrix” or a “collection of vectors”?
1 Like
A is itself a matrix but you can also look at it as a collection of column vectors or row vectors.
jesbu1
January 27, 2019, 3:08am
3
Part 4 is taking an insanely long amount of time to run, can we do this experiment with matrices of smaller sizes?
Mine finished in about 140 seconds. I think it is correct.
Is there a better way to loop over the vectors? I’m using range() and it’s taking super long.
And using nd.arange() kills my kernel for some reason.
1 Like
I looped over too using outer products. It killed my kernel when I first implemented it but then after I fixed something it can compute in 2 minutes.
I thought we were supposed to use dot products?
FYI my part 4 “only” took 5000 secs LOL
jesbu1
January 27, 2019, 5:51pm
9
Yeah my part took 4000 seconds lol
By outer product I meant uv.T using dot product.
ihsj10
January 28, 2019, 2:06am
11
Feel like I’m doing something wrong for parts 3 and 4 while iterating through the columns for vector dot products… about how long should each run for?
yuhongc
January 28, 2019, 6:57pm
12
Mine ran for 3000 seconds for part 4. I can’t seem to find a better solution though.
ihsj10
January 28, 2019, 7:12pm
13
my kernel keeps dying after around 10min, how did you end up getting around that?
yuhongc
January 28, 2019, 7:26pm
14
Are you using arange() for your loops? They have a strange tendency of killing kernels. I switched to the native range() and was fine after that. I have no idea why though.
smolix
January 29, 2019, 12:40am
15
The main point is to get the message across that it takes a stupidly long time not to use efficient vectorization. As a side effect, you’ll never write inefficient code that doesn’t use acceleration again
1 Like