Skip to main content

A neural network library for beginners.

Project description

Monkey – Simple Neural Networks for Beginners

Monkey is a lightweight Python library for building, training, and experimenting with simple neural networks.
It is designed for beginners who want to understand how neural networks work internally without heavy dependencies.


Features

  • Fully connected neural networks (Dense layers)
  • Activation functions: ReLU, Sigmoid, Tanh, Linear
  • Train networks using gradient descent with multiple optimizers
  • Supports SGD, Adam, RMSProp, and AdaGrad
  • Works with Python lists or NumPy arrays
  • Autoencoder-style training (no labels required)
  • Sequence prediction using next-step training
  • Lightweight AttentionBlock for sequence inputs
  • Save and load models using .mon format
  • Minimal and beginner-friendly API

Installation

pip install monkey

Quick Start

Predict the sum of two numbers

from monkey import NeuralNet

x_train = [[2, 8], [9, 3], [7, 4], [1, 1]]
y_train = [[sum(pair)] for pair in x_train]

nn = NeuralNet(input_size=2)
nn.add_layer(neurons=5, activation='relu')
nn.add_layer(neurons=1, activation='relu', layer='output')

nn.train(x_train, y_train, epochs=500, lr=0.1)

print(nn.predict([3, 5])[0])

Using different optimizer

from monkey import NeuralNet

x_train = [[2, 8], [9, 3], [7, 4], [1, 1]]
y_train = [[sum(pair)] for pair in x_train]

nn = NeuralNet(input_size=2, optimizer="adam")

nn.add_layer(4, activation="relu")
nn.add_layer(1, activation="linear", layer="output")

nn.train(x_train, y_train, epochs=500)

print(nn.predict([3, 5])[0])

Autoencoder (no labels)

from monkey import NeuralNet

data = [[0], [1], [2], [3], [4], [5]]

nn = NeuralNet(input_size=1)
nn.add_layer(3, activation="relu")
nn.add_layer(1, activation="linear", layer="output")

nn.train(data, epochs=200)

print(nn.predict([2]))

Sequence prediction (next-step learning)

from monkey import NeuralNet

sequence = [1, 2, 3, 4, 5, 6]

nn = NeuralNet(input_size=1)
nn.add_layer(5, activation="relu")
nn.add_layer(1, activation="linear", layer="output")

nn.train(sequence, epochs=300, next_step=True)

print(nn.predict([6]))

AttentionBlock example

from monkey import AttentionBlock

seq_input = [
    [0.8, 0.2, 0.1],
    [0.5, 0.1, 0.3],
    [0.2, 0.7, 0.6]
]

attn = AttentionBlock(input_size=3, output_size=3)
output = attn.forward(seq_input)

print(output)

Model Saving and Loading

from monkey import save, load

save(nn, "model.mon")

loaded = load("model.mon", use_numpy=True)

print(loaded.predict([3, 5]))

Available API (Public)

Core

  • NeuralNet → Create and train networks
  • Dense → Internal fully connected layer

Activations

  • relu
  • sigmoid
  • tanh
  • linear
  • activation_map

Attention

  • AttentionBlock

Optimizers

  • SGD
  • Adam
  • RMSProp
  • AdaGrad

Models

  • save
  • load

Global

  • useNumpy → Toggle NumPy usage (True / False)

Notes

  • Only .mon model format is supported
  • Works with both Python lists and NumPy arrays
  • If NumPy is unavailable, pure Python mode is used
  • next_step=True enables sequence learning
  • If y_train=None, autoencoder training is used automatically

Learning Tips

  • Start with small datasets
  • Use fewer neurons to understand behavior
  • Try different activations to observe changes
  • Experiment with optimizers
  • Use AttentionBlock for sequence understanding

Repository

https://github.com/19919rohit/Neural-Monkey


License

MIT License

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

neural_monkey-0.3.1.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

neural_monkey-0.3.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file neural_monkey-0.3.1.tar.gz.

File metadata

  • Download URL: neural_monkey-0.3.1.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for neural_monkey-0.3.1.tar.gz
Algorithm Hash digest
SHA256 242a4fc045320c1b08e7ef072115ef957cbdc9c50974df54d046911846b468c5
MD5 ff5cd87f754c2ffebdb17b9e6156c117
BLAKE2b-256 09217d405b597d492f5d44679e36a59730edb4c816175a56124e2c056a64bd72

See more details on using hashes here.

File details

Details for the file neural_monkey-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: neural_monkey-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for neural_monkey-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 df20e3de9a049543380549c1bd1317a75138eda7d41e40ddf946e6be8a87d9be
MD5 5b5900371c91c67c934acb83b712d7cf
BLAKE2b-256 cae5a22486d874323924aa788b1a04d4e2f6c1bf734039af543bad4704015ac5

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