Skip to main content

A fierce Tensorflow competitor

Project description

Python PyPI - Version GitHub Actions Workflow Status GitHub Release Date

[!IMPORTANT] This is an elaborate meme I put a lot of effort into. So please, no one sue me.

ShamboFlow is an open source API for creating machine learning models. It is only available in python.

ShamboFlow is super fast drop in replacemnet for TensorFlow (Read adds nothing, not even performance improvement). It is build from scratch (Read, using numpy) and comes with Cuda GPU support out of the box. I will tell the story at the end of this file on how this came to be.

On a serious note, I always wanted to implement a neural network using just numpy and no additional libraries and this gave me an excuse to do so. And so I did. I made this in a week. Learned a lot of stuff in the process and it was a stressfull and fun experience. This library is dependent on numpy as stated but also uses cupy to add GPU support. Other two dependencies are tqdm for progress bar and colorama for colorful texts. I will probably work more on this as I have already put in quite some effort.

Documentation

Static Badge

Install

Install using the pip package.

$ pip install shamboflow

To update ShamboFlow to the latest version, add --upgrade flag to the above command

Example

A small example program that shows how to create a simple ANN with 3-2-1 topology and train it with data to perform predictions.

Define the model and train it

import numpy as np

# Dataset
x_data = np.array([[1, 0, 1]])
y_data = np.array([[1]])

# Parameters
learning_rate = 0.9
train_epochs = 20

# Import the library
import shamboflow as sf

# Create a model
model = sf.models.Sequential()
# Add layers
model.add(sf.layers.Dense(3))
model.add(sf.layers.Dense(2, activation='sigmoid'))
model.add(sf.layers.Dense(1, activation='sigmoid'))

# Compile the model
model.compile(learning_rate=learning_rate, loss='mean_squared_error', verbose=True)

# Callbacks
checkpoint = sf.callbacks.ModelCheckpoint(monitor='loss', save_best_only=True, verbose=True)

# Train the model with the dataset
model.fit(
    x_data,
    y_data,
    epochs=train_epochs,
    callbacks=[checkpoint]
)

# Save the trained model to disk
model.save('model.meow')

Load the saved model and predict

import numpy as np
import shamboflow as sf

model = sf.models.load_model("./model.meow")

a = np.array([[1, 0, 1]])

res = model.predict(a)
print(res)

Story

Its storytime.

Last week we had a class on Neural Networks at university. At the end of the class, our professor told us to implement the given network in python. Now, previously he had told us to not use any libraries to perform our tasks as that would just ruin the purpose of learning algorithms. So, I got excited that I am gonna implement a neural network using just python. Then he told us that we can use libraries for making the network. And I was a little bummed. My friend jokingly told me that, "No you have to make it". And I said, if I finish it within a week, will you use it in the assignment. My friends agreed to it.

So, here it is. My library. I am so gonna make them use this for the assignments.

v1.0.0.1

Very minor release. Made this scratch an itch.

  • Change logo in README from local to cdn. MIT License

Copyright (c) 2024 ShambaC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shamboflow-1.0.0.1.tar.gz (15.9 kB view hashes)

Uploaded Source

Built Distribution

shamboflow-1.0.0.1-py3-none-any.whl (17.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page