A Cython-based tensor and autograd library
Project description
🔥 CGrad
⏭️🥅 Next goal:
-
Grad engine-> new task:matmul/div autograd.-> scaler part still remaining. -
randn Generator-> with seed - Make the Tensor fast: Check the
tensor.candTensorwrapper.pyxfiles again, and try to optimize them to make them faster. - stop using numpy -> add the reshape, and other stuff.
- Build a Tensor for Int, Double, Long, etc.
- Use the Fast matrix multiplication algorithm to reduce the time complexity.
- Make loss dir and make loss like "Tenh, ReLU, sigmoid, softmax" in a more optimistic way. -> Make the
lossfolder, but you also need to make the backward pass for it. - Make Optimizer start with SGD in C not in pyx (aka cython) -> after SGD -> Adam ...
✨ Overview
Lightweight library for performing tensor operations. CGrad is a module designed to handle all gradient computations, and most matrix manipulation and numerical work generally required for tasks in machine learning and deep learning. 🤖📚
💡 Features
- 🌀 Support for n-dimensional tensor operations.
- 🤖 Automatic differentiation for gradient computation.
- 🛠️ Built-in functions for common tensor operations like addition, multiplication, dot product, etc.
⚙️ Installation
For user:
pip install cgrad==0.0.1
For Contributers
-
install MinGWfor Windows user install latest MinGW. -
install gccfor Mac or Linux user install latest gcc. -
clone the repository and install manually:
git clone https://github.com/Ruhaan838/CGrad
python setup.py build_ext --inplace pip install .
🚀 Getting Started
Here’s a simple guide to get you started with CGrad:
📥 Importing the module
import cgrad
📦 Creating Tensors
You can create a tensor from a Python list or NumPy array:
# Creating a tensor from a list
tensor = cgrad.Tensor([1.0, 2.0, 3.0])
# Creating a tensor with a specified shape
tensor = cgrad.Tensor([[1.0, 2.0], [3.0, 4.0]])
🔄 Basic Tensor Operations
CGrad supports basic operations like addition, multiplication, etc.:
# Tensor addition
a = cgrad.Tensor([1.0, 2.0, 3.0])
b = cgrad.Tensor([4.0, 5.0, 6.0])
result = a + b # Element-wise addition
# Tensor multiplication
c = cgrad.Tensor([[1.0, 2.0], [3.0, 4.0]])
d = cgrad.Tensor([[5.0, 6.0], [7.0, 8.0]])
result = c * d # Element-wise multiplication
📐 Advance Tensor Operations
CGrad supports advanced operations like matrix multiplication etc.:
a = cgrad.randn((1,2,3))
b = cgrad.randn((5,3,2))
result = a @ b
Note: cgrad.matmul is still underdevelopment.
🔥 Gradient Computation
CGrad automatically tracks operations and computes gradients for backpropagation:
# Defining tensors with gradient tracking
x = cgrad.Tensor([2.0, 3.0], requires_grad=True)
y = cgrad.Tensor([1.0, 4.0], requires_grad=True)
# Performing operations
z = x * y
# Backpropagation to compute gradients
z.backward()
# Accessing gradients
print(x.grad) # Gradients of x
print(y.grad) # Gradients of y
📖 Documentation
For more detailed information, please visit our documentation website.
🤝 Contributing
I ❤️ contributions! If you’d like to contribute to CGrad, please:
You can contribute to code improvement and documentation editing.
If any issue is found, report it on the GitHub issue
- 🍴 Clone the repository.
- 🌱 Create a new branch for your feature or bugfix.
- ✉️ Submit a pull request.
📖 Reading
📝 License
📜 See LICENSE for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cgrad-0.0.1.tar.gz.
File metadata
- Download URL: cgrad-0.0.1.tar.gz
- Upload date:
- Size: 263.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
003157529eefe60cddb1eefb351f4e5e14679d8304d3b3563fab29ce35fea037
|
|
| MD5 |
1a2f4d71f32d7ee1be7176f44a5f05d5
|
|
| BLAKE2b-256 |
2fd19b4d832ffbed44dbee0ed1927df8c879982969dc20ea03646873de1658bb
|
File details
Details for the file cgrad-0.0.1-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: cgrad-0.0.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 141.6 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edba68e927ebeaa21bddcc13df65e4f09d75733e875a9b79274512e06406d845
|
|
| MD5 |
ace4e3f7d2d2a18634b33162f3d193e4
|
|
| BLAKE2b-256 |
71b305ac6d8dc98b7942d9e047b7a6b4135d7f6c143d5f533847e285c91b5707
|