No description
Find a file
2024-05-16 17:25:16 -03:00
.github/workflows Create python-publish.yml 2024-05-10 20:21:23 -03:00
build add broadcasted operation cuda 2024-05-16 17:25:16 -03:00
examples small changes 2024-05-10 20:12:15 -03:00
norch add broadcasted cuda 2024-05-16 17:23:38 -03:00
tests sub broadcasted cpu autograd 2024-05-16 17:03:09 -03:00
README.md Merge branch 'main' into tmp 2024-05-11 14:38:37 -03:00
setup.py Small fix for PiPy 2024-05-11 01:49:35 -03:00

PyNorch

Recreating PyTorch from scratch (C/C++, CUDA and Python, with GPU support and automatic differentiation!)

1 - About

PyNorch is a deep learning framework constructed using C/C++, CUDA and Python. This is a personal project with educational purpose only! Norch means NOT PyTorch, and we have NO claims to rivaling the already established PyTorch. The main objective of PyNorch was to give a brief understanding of how a deep learning framework works internally. It implements the Tensor object, GPU support and an automatic differentiation system.

2 - Installation

Install this package from PyPi (you can test on Colab!)

$ pip install norch

or from cloning this repository

$ sudo apt install nvidia-cuda-toolkit
$ git clone https://github.com/lucasdelimanogueira/PyNorch.git
$ cd build
$ make
$ cd ..

3 - Get started

3.1 - Tensor operations

import norch

x1 = norch.Tensor([[1, 2], 
                  [3, 4]], requires_grad=True).to("cuda")

x2 = norch.Tensor([[4, 3], 
                  [2, 1]], requires_grad=True).to("cuda)

x3 = x1 @ x2
result = x3.sum()
result.backward

print(x1.grad)

3.2 - Create a model

import norch
import norch.nn as nn
import norch.optim as optim

class MyModel(nn.Module):
    def __init__(self):
        super(MyModel, self).__init__()
        self.fc1 = nn.Linear(1, 10)
        self.sigmoid = nn.Sigmoid()
        self.fc2 = nn.Linear(10, 1)

    def forward(self, x):
        out = self.fc1(x)
        out = self.sigmoid(out)
        out = self.fc2(out)
        
        return out

4 - Progress

Development Status Feature
Operations in progress
  • [ ] Broadcasting
Loss in progress
  • [x] MSE
  • [ ] Cross Entropy
Data in progress
  • [ ] Dataset
  • [ ] Batch
  • [ ] Iterator
Convolutional Neural Network in progress
  • [ ] Conv2d
  • [ ] MaxPool2d
  • [ ] Dropout
Distributed in progress
  • [ ] Distributed Data Parallel