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

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.

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.1.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

shamboflow-1.0.1-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file shamboflow-1.0.1.tar.gz.

File metadata

  • Download URL: shamboflow-1.0.1.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for shamboflow-1.0.1.tar.gz
Algorithm Hash digest
SHA256 9288c3922d57f4dc976b6c68b28847df9b832ff19111a981d7db8c4de5585d4f
MD5 3e48d03eeea24dab2a590e5c4d55f60b
BLAKE2b-256 6185bdeb33f1881f623a5665289c31a27846126d5a149b4db7c05a0dad9682b2

See more details on using hashes here.

File details

Details for the file shamboflow-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: shamboflow-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for shamboflow-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 91e954fd415fb7a2cd15d00076e1d60d8028f4b5fd3c9063b277ff3d6707f15a
MD5 fbfa2d1437cd2954c91f34460629df58
BLAKE2b-256 9129843517ebbfd934046a55f913336255fa580c37af5d77eb6aec811785e3f8

See more details on using hashes here.

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