If we are doing matmul then shouldn’t we be using Strassen’s algorithm?
Is there a way to just get the items out of the map object without assigning them? Say I just want to print the value of items
O(N^2.8)
The goal is to explain it in a very simple way for now.
Also, to complete my answer, I’m not entirely sure Strassen’s algorithm can be fully parallelized (which is what we do in GPU).
You can write a foreach on the generator and print each elements.
I believe that map object behaves like an iterator, and doesn’t provide a random-access interface. Therefore, you can only consume one item after another, as you do with streams.
But you can wrap it in list, like:
list(map(tensor, (x_train,y_train,x_valid,y_valid)))
if you really want a true list
Are we going to learn how it is implemented on a GPU efficiently?
Or more pythonic:
[tensor(data) for data in (x_train,y_train,x_valid,y_valid)]
Yeah, essentially list is doing it for you: it consumes everything up to the end of the iterator. Note that it could take some time and occupy memory if you have a really long sequence. Like, if you only need to go through the items one time, it is probably better to keep it an iterator.
Wouldn’t a non-vectorized implementation of matrix multiplication be slow in any language, even C? Is Python really the reason this matmul is slow, or just that it is non-vectorized?
To be clear, this * in the code for the Frobenius norm is the element-wise multiplication right, not the matrix multiplication ?
What does the operations on your vectors once it’s vectorized? Python is faster when you vectorize things because you fall in C code written for numpy.
Always liked maps instead of for loops for doing something over a data structure like a list.
Yes, matrix multiplication is @
Not nearly as slow as it is in Python.
Agree, I like “functional” tricks in Python as well
Though sometimes the code becomes less clear if you have too many of them.
Shouldn’t one of the m be m.transpose()?
It’s elementwise matrix multiplication.
I think Numpy is fast because it is taking advantage of SIMD (single instruction, multiple data), not just because it is in C. But I know very little about Numpy internals.