Skip to main content

A slower machine learning framework

Project description

Tensorslow

Tensorslow Logo

Have you ever wanted to to use the power of neural network modeling with absolutely NONE of the rush given by competing neural network frameworks? Well if you answered yes to the previous question then Tensorslow is the machine learning framework to use. Using state of the art Python3 lists rather than any complicated and vectorized backends from languages of yester-year like C++, we seek to use the Zen of Python to make your machine learning models learn at a pace more compatible with that of your three remaining brain-cells (or at least mine). So, get ready to sit back, take a sip of that green-tea, and enjoy the magic of machine learning with absolutely NONE of the stress provided by a machine that works way too quickly for its own good.

Install

To download the code from the repository

git clone git@github.com:oortega20/tensorslow.git

To install the current release of Tensorslow

pip install tensorslow

Try some simple Tensorslow Programs

Some fun matrix manipulations with tensorslow's linear-algebra package

>>> from tensorslow.linalg import Tensor
>>> x = Tensor(list(range(6)), (2,3))
>>> x
Tensor([[0.000 1.000 2.000]
        [3.000 4.000 5.000]])
>>> x @ x.T
Tensor([[5.000 14.000]
        [14.000 50.000]])
>>> x.T @ x
Tensor([[9.000 12.000 15.000]
        [12.000 17.000 22.000]
        [15.000 22.000 29.000]])
>>> x - 3
Tensor([[-3.000 -2.000 -1.000]
        [0.000 1.000 2.000]])
>>> 0 * x
Tensor([[0.000 0.000 0.000]
        [0.000 0.000 0.000]])

A simple demonstration of forward propagation with Tensorslow's available layers and activations

>>> from tensorslow.linalg import Tensor
>>> from tensorslow.activations import Relu
>>> from tensorslow.layers import Dense
>>>
>>> x = Tensor(list(range(6)), (2,3))
>>> x
Tensor([[0.000 1.000 2.000]
        [3.000 4.000 5.000]])
>>> act = Sigmoid()
>>> f = Dense('f', in_dim=3, out_dim=3)
>>> f.weights['w']
Tensor([[0.057 0.051 0.021]
        [0.047 -0.031 0.003]
        [0.015 -0.052 0.058]])
>>> f.weights['b']
Tensor([0.333 0.333 0.333])
>>> out = act(f(x))
>>> out
Tensor([[0.601 0.549 0.611]
        [0.682 0.525 0.667]])
>>>

Inference using Tensorslow MNIST Classifier

from tensorslow.datasets import MNIST
from tensorslow.models import ts_mnist_classifier

model = ts_mnist_classifier(from_ts=True)
data = MNIST(load_train=False, load_test=True, batch_size=128)
x_test, y_test = data.get_test_data()
for x, y in zip(x_test, y_test):
    probs = model.forward(x) # if we only want the class probabilities
    loss, grad = model.forward(x, y) # if we want to compute losses and gradients

Example of simple model training using tensorslow

from tensorslow.datasets import MNIST
from tensorslow.models import ts_mnist_classifier
from tensorslow.optimizers import SGD


data = MNIST(batch_size=128)
x_train, y_train = data.get_train_data()
epochs = 10
model = ts_mnist_classifier(from_ts=False)


opt = SGD(model, learning_rate=5e-4)
train_loss, test_loss = [], []
for epoch in range(epochs):
    for data in zip(x_train, y_train):
        x, y = data
        batch_loss, grad = model(x, y)
        model.backward(grad)
        opt.update()

Details of the Tensorslow MNIST Classifier can be found in a link to our tensorslow-experimentation repository. Improving the accuracy of the current MNIST classifier is something being researched!

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

tensorslow-1.0.3.tar.gz (16.8 MB view hashes)

Uploaded Source

Built Distribution

tensorslow-1.0.3-py3-none-any.whl (3.4 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