Skip to main content

This is the small library for deep learning.

Project description

This is Grand Lantern neural network library рџЏ®

The main purpose of this library is to understand - what is happening under the hood of popular deep learning frameworks. Also, it can be used to build your own ideas - no special knowledge for thst you need!

This library is written only using numpy (maybe cupy in future), you can see every calculation in neural network!

How to install в›ЏпёЏ

Just put this command to terminal

pip install grandlantern

Get started рџљЂ

1. Import library

import grandlantern

2. Define Data Iterator

from grandlantern.dataiterators import DatasetIterator, TableDataset

batch_size = 100
my_dataset_iterator = DatasetIterator(dataset=TableDataset(), batch_size=batch_size)

3. Choose optimizer

from grandlantern.optimizers import SGD

my_optimizer = SGD(learning_rate=0.01)

4. Build model

from grandlantern import model
from grandlantern.metrics import CrossEntropy, Accuracy

NN = model(n_epochs=100,
           dataset_iterator=my_dataset_iterator,
           loss_function=CrossEntropy(),
           metric_function=Accuracy(),
           optimizer=my_optimizer)

5. Add layers

from grandlantern.layers import LinearLayer
from grandlantern.layers import Sigmoid, ReLU, SoftMax

NN.add_layer(LinearLayer(n_neurons=100, activation=Sigmoid(), biased=True))
NN.add_layer(LinearLayer(n_neurons=50, activation=ReLU(), biased=True))
NN.add_layer(LinearLayer(n_neurons=10, activation=SoftMax(), biased=True))

Also layers can be added using attribute model.layers:

from grandlantern.layers import LinearLayer
from grandlantern.layers import Sigmoid, ReLU, SoftMax

NN.layers = 
[
    LinearLayer(n_neurons=100, activation=Sigmoid(), biased=True),
    LinearLayer(n_neurons=50, activation=ReLU(), biased=True)
    LinearLayer(n_neurons=10, activation=SoftMax(), biased=True)
]

To look at the model structure the command print can be used:

print(NN)

6. Train model

Inputs for training must be numpy arrays. There is also option to validate model on test data while training (X_test and y_test are optional).

NN.fit(X_train, y_train, X_test, y_test)

7. Use model

Input for prediction must be numpy array.

y_pred = NN.predict(X_test)

What is supported now вњ…

Layers

  • Linear Layer (LinearLayer)
  • Image Convolutional Layer (Conv2DLayer)
  • Batch Normalization Layer (BatchNormLayer)
  • Recurrent Layer (RecurrentLayer)
  • RNN Layer (RNNLayer)
  • Flatten Layer (FlattenLayer)

Optimizers

  • SGD
  • NAG
  • Adagrad
  • Adam

Datasets and Iterators

  • Dataset Iterator with shuffle
  • Table Dataset
  • Image Dataset
  • Sequence Dataset

Regularization

  • L1, L2, Elastic Net
  • Dropout Layer (DropOutLayer)

What will be done рџ“ќ

New Layers

  • Bidirectional RNN
  • LSTM, GRU layers
  • Attention layers
  • Seq2seq model
  • Transformers
  • Pooling layers

GPU Accelaration using cupy

Some more optimizers

Preprocessing modules

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

grandlantern-0.0.20.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grandlantern-0.0.20-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file grandlantern-0.0.20.tar.gz.

File metadata

  • Download URL: grandlantern-0.0.20.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for grandlantern-0.0.20.tar.gz
Algorithm Hash digest
SHA256 d14814529df1a5e61b69e6242e0c12b396fb0f5abcf30359515c6bbc465c1243
MD5 76f5dd607e06ede23f1d54e1c74d2e7a
BLAKE2b-256 59ceeebce71f011c6e0d3807af173bfd896804693194a62127d05600e7959c0b

See more details on using hashes here.

File details

Details for the file grandlantern-0.0.20-py3-none-any.whl.

File metadata

  • Download URL: grandlantern-0.0.20-py3-none-any.whl
  • Upload date:
  • Size: 25.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for grandlantern-0.0.20-py3-none-any.whl
Algorithm Hash digest
SHA256 2522e26555a61cbf0b230c88b303196e299d7211c5ac79f7df6110cb6af300c5
MD5 0d7d9b793795ed86a0eae848a734ae91
BLAKE2b-256 6b3d9bd49853f24c7d27d12017da3a8105cc7699585e85b1a8f65f9c59a108e5

See more details on using hashes here.

Supported by

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