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 neural-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.2.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.2-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: neural_monkey-0.3.2.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.2.tar.gz
Algorithm Hash digest
SHA256 d54e814f89d462b5cc616ff032fa45ba3397253f4d6ff05dda8f8fe62b1169c1
MD5 8e0319fd996ba1918e79b08f27325936
BLAKE2b-256 b5c685fee6cdf875fa19d4e4a3e6598a858256488c9517562facddea12f78a3b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neural_monkey-0.3.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 522ebc398470c8612045b066797a9e72313bd5f40a75ec8417f7e9c123b204d0
MD5 83b00771aee84f2be3608dfc2425735e
BLAKE2b-256 14af567a5d2bfd3dbe08d7f4c7f24e1f0e2f28b5d879ae7c39a544e7f4ea45ef

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