Skip to main content

A Pure Numpy Deep Learning Framework

Project description

A pure Numpy deep learning framework with a modular Keras-like API.

Installation

From PyPI:

$ pip install learnnn

From source:

$ python setup.py install

Usage

MNIST handwritten digits classification example:

from learnnn.datasets import MNIST
from learnnn.activations import ReLU, Sigmoid
from learnnn.losses import MeanSquaredError
from learnnn.optimizers import Momentum
from learnnn.initializers import RandomUniform, Zeros
from learnnn.metrics import CategoricalAccuracy
from learnnn.layers import Dense, Dropout
from learnnn.models import FeedForwardNetwork
from learnnn.utils.data import one_hot_encode, normalize

dataset = MNIST()
(X_train, y_train), (X_test, y_test) = dataset.training_data(), dataset.test_data()
X_train, X_test = normalize(X_train, X_test)
y_train, y_test = one_hot_encode(y_train), one_hot_encode(y_test)

model = FeedForwardNetwork()
model.add(Dense(units=100,
                activation=ReLU(),
                weights_initializer=RandomUniform(scale=0.01),
                bias_initializer=Zeros(),
                input_shape=(784,)))
model.add(Dropout(drop_percent=0.3))
model.add(Dense(units=10,
                activation=Sigmoid(),
                weights_initializer=RandomUniform(scale=0.01),
                bias_initializer=Zeros()))
model.compile(optimizer=Momentum(learning_rate=0.01, nesterov=True, clip_value=0.05),
              loss=MeanSquaredError(),
              metrics=[CategoricalAccuracy()])

model.fit(X_train, y_train, batch_size=32, epochs=50)
loss, metrics = model.evaluate(X_test, y_test, batch_size=32)
print("Test Loss :", loss)
print("Test Metrics :", metrics)

Output:

examples/mnist_demo_output.gif

Included Components

Layers Dense
Dropout
Activations ReLU
Sigmoid
Optimizers Stochastic Gradient Descent (SGD)
SGD with Momentum
Losses Mean Squared Error
Weight Initializers Zeros
Random Uniform
Metrics Categorical Accuracy
Datasets MNIST handwritten digits
Synthetic - Moons, Spirals

Downloading Datasets

$ python -m learnnn --download {dataset_name}

List available commands:

$ python -m learnnn -h

Project details


Release history Release notifications

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
learnnn-0.1.0-py3-none-any.whl (17.3 kB) Copy SHA256 hash SHA256 Wheel py3
learnnn-0.1.0.tar.gz (8.5 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page