3 ms·
“from scratch” == “using numpy and numba”
by p1esk 5y ago
“from scratch” == “using numpy and numba”
- shard 5y agoIf you wish to implement the Torch API from scratch, you must first invent the universe. (Apologies to Sagan)
- p1esk 5y ago"from scratch" in this context does not make any sense - Pytorch is already implemented "from scratch" using Python, C++, and CUDA. Implementing Pytorch using Numpy is the opposite of "from scratch".
- shard 5y agoI didn't dig too deeply, however on the pytorch installation page, it says "Please ensure that you have met the prerequisites below (e.g., numpy)" Does pytorch already require numpy?
- p1esk 5y agoIt does, because it can convert a numpy array to a pytorch tensor and back, but I don’t think numpy is used for anything else.
- lostmsu 5y agoThey must be doing something else with numpy as Python has a generic API, that allows direct access to data of numpy array-like structures: Buffer Protocol https://docs.python.org/3/c-api/buffer.html https://docs.python.org/3/c-api/buffer.html
- p1esk 5y agoIt’s not just about access to underlying data - users might want to import from, or export to numpy array (e.g. for visualization, etc).
- lostmsu 5y agoBuffer protocol means PyTorch can have a torch.tensor method, that can create a tensor of anything implementing this protocol (which NumPy arrays do), and likewise numpy.array can be constructed out of PyTorch array because PyTorch Tensor implements this protocol. E.g. they don't need to know about each other (so no dependency), only about the protocol.
- rg111 5y agoThis material is focused on teaching how to develop a Deep Learning library, and not teaching Deep Learning through implementing things from scratch. If that's what you want, then there are: - Data Science from Scratch - Deep Learning from Scratch
- p1esk 5y agoIt's totally fine if you want to implement a DL library using Numpy. Just don't call it "from scratch". Especially if you say "in pure Python". Numpy is just as "pure Python" as Pytorch, so this does not make much sense.
- rg111 5y agoThis is focused on API Design. Not on developing a DL library from scratch.