a beautifully simplistic ml framework
Project description
froog
froog: fast real-time optimization of gradients
a beautifully compact machine-learning library
homepage | documentation | pip
froog
is an easy-to-read machine-learning library.
froog
is meant for those looking to get into machine learning, who want to understand how the underlying machine learning framework's code works before they are ultra-optimized (which all modern ml libraries are).
froog
encapsulates everything from linear regression to convolutional neural networks
all of this in under 1000 lines.
Installation
pip install froog
More information on downloading froog
in the installation docs.
Features
- Custom Tensors
- Backpropagation
- Automatic Differentiation (autograd)
- Forward and backward passes
- ML Operations
- 2D Convolutions (im2col)
- Numerical gradient checking
- Acceleration methods (Adam)
- Avg & Max pooling
- EfficientNet inference
- GPU Support
- and a bunch more
Sneak Peek
from froog.tensor import Tensor
from froog.nn import Linear
import froog.optim as optim
class mnistMLP:
def __init__(self):
self.l1 = Tensor(Linear(784, 128))
self.l2 = Tensor(Linear(128, 10))
def forward(self, x):
return x.dot(self.l1).relu().dot(self.l2).logsoftmax()
model = mnistMLP()
optim = optim.SGD([model.l1, model.l2], lr=0.001)
Overview
The most fundamental concept in all of froog
and machine learning is the Tensor. A tensor is simply a matrix of matrices (more accurately a multi-dimensional array).
You can create a Tensor in froog
by:
import numpy as np
from froog.tensor import Tensor
my_tensor = Tensor([1,2,3])
Notice how we had to import numpy. If you want to create a Tensor manually make sure that it is a Numpy array!
Learn more about froog
Tensors here.
Actually creating something
Okay cool, so now you know that froog
's main datatype is a Tensor and uses NumPy in the background. How do I actually build a model?
We wanted to make it as simple as possible for you to do so.
Here's an example of how to create an MNIST multi-layer perceptron (MLP)
from froog.tensor import Tensor
import froog.optim as optim
from froog.nn import Linear
class mnistMLP:
def __init__(self):
self.l1 = Tensor(Linear(784, 128))
self.l2 = Tensor(Linear(128, 10))
def forward(self, x):
return x.dot(self.l1).relu().dot(self.l2).logsoftmax()
model = mnistMLP()
optim = optim.SGD([model.l1, model.l2], lr=0.001)
You can also create a convolutional neural net by
class SimpleConvNet:
def __init__(self):
conv_size = 5
channels = 17
self.c1 = Tensor(Linear(channels,1,conv_size,conv_size)) # (num_filters, color_channels, kernel_h, kernel_w)
self.l1 = Tensor(Linear((28-conv_size+1)**2*channels, 128)) # (28-conv+1)(28-conv+1) since kernel isn't padded
self.l2 = Tensor(Linear(128, 10)) # MNIST output is 10 classes
def forward(self, x):
x.data = x.data.reshape((-1, 1, 28, 28)) # get however many number of imgs in batch
x = x.conv2d(self.c1).relu() # pass through conv first
x = x.reshape(shape=(x.shape[0], -1))
return x.dot(self.l1).relu().dot(self.l2).logsoftmax()
Contributing
Pull requests will be merged if they:
- increase simplicity
- increase functionality
- increase efficiency
More info on contributing
Documentation
Need more information about how froog
works? Visit the documentation.
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
File details
Details for the file froog-0.2.8.tar.gz
.
File metadata
- Download URL: froog-0.2.8.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83891fea3b256cb0bf3c03a9a52ea1a6c4df7de7415e3ad881050577cd4696aa |
|
MD5 | 47ab35c0b2ac06c563a4bcc6b76dd819 |
|
BLAKE2b-256 | ce813c4246667ecbbe7c183111673ab8f4586c49bbd67bbd6ba52d4f6baebdbe |
File details
Details for the file froog-0.2.8-py3-none-any.whl
.
File metadata
- Download URL: froog-0.2.8-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e491a0e60623180b7d89404cb3c9a9b45fd1f9f8d58c6bf4c19dea79eb2b146e |
|
MD5 | e4dee52b55ed6805ed74b1ca07b90e1b |
|
BLAKE2b-256 | 24d64912daffcb33ac32b42a42310d540505c2ffa62c7ad0d6a7b61efbc3895f |