🔥 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.
Metadata
Release files for cgrad 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cgrad-0.0.2.tar.gz | 269.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cgrad-0.0.2-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
Total release size: 411.3 kB
Release files / cgrad-0.0.2.tar.gz
| Download URL | cgrad-0.0.2.tar.gz |
|---|---|
| Size | 269.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
65f8979887aa95416dcbda90a0ea9c55ca8b1a2a86b37f2c6ca5ddf0d8d22ec2
|
|
BLAKE2b-256 checksum How to use checksums |
61a5f3b82a756cf22313df9f01d61e8f159b17ec4cb2f1fafea9c64e7983e694
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / cgrad-0.0.2-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | cgrad-0.0.2-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 141.6 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
a829de2a9e0f823f03c3b6f7f569560f9da6996443990fca395d906c9d948fc3
|
|
BLAKE2b-256 checksum How to use checksums |
3e82532c4f0285bda7f8c815d594a727334afa247ead1ee05213645f54e4b877
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|