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

Uploaded Python 3

File details

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

File metadata

  • Download URL: neural_monkey-0.3.3.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.3.tar.gz
Algorithm Hash digest
SHA256 a8cc6fcd6fb6537d01a147d8a0cb9a6f79fde9844b867aa4a71a0b0bf8ad8234
MD5 54fc0d0962bcded808327f527fed25c0
BLAKE2b-256 dea0a97479877843bcbdd7e45d5c704f4044dfbab76ba3f3fbec5b5ab5409d06

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neural_monkey-0.3.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f40bef253cf839013cf168691ab95202a8a8af72db2e5bc9563d1edecead1565
MD5 14be588539d3d868e292aba74b39dcf5
BLAKE2b-256 3a3e2fbeaeacc3e38dcfa8c8efd3cf3eeaba8f69f29fb721a8aba3d1ae7e865d

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