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 and training simple neural networks.
It is designed for beginners to learn concepts like layers, activations, forward propagation, backpropagation, and simple attention mechanisms in a fun and interactive way.


Features

  • Create fully connected neural networks (Dense layers)
  • Choose activation functions: ReLU, Sigmoid, Tanh
  • Train networks using gradient descent with adjustable learning rate and epochs
  • Make predictions on new inputs
  • Optional lightweight AttentionBlock for sequence inputs
  • Beginner-friendly API with minimal setup
  • Fully Python-based, no external dependencies

Installation

pip install monkey

Quick Start Examples

1. Predict the sum of two numbers

from monkey.nn import NeuralNet

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

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

# Train the network
nn.train(x_train, y_train, epochs=500, lr=0.1)

# Predict
print("Prediction for [3,5]:", nn.predict([3,5])[0])

2. Predict using Sigmoid activation

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

nn.train(x_train, y_train, epochs=1000, lr=0.05)
print("Prediction for [2,2]:", nn.predict([2,2])[0])

3. Using AttentionBlock for sequences

from monkey.attention 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)
seq_output = attn.forward(seq_input)

print("Attention output:", seq_output)

API Reference

Class / Function Description
NeuralNet Core class for creating and training fully connected networks
NeuralNet.add_layer Add a layer to the network; choose neurons, activation, layer type
NeuralNet.predict Make predictions for a given input
NeuralNet.train Train the network on input/output data
AttentionBlock Simple attention mechanism for sequences
relu(x) Rectified Linear Unit activation function
sigmoid(x) Sigmoid activation function
tanh(x) Tanh activation function

Layer Parameters in add_layer:

  • neurons: Number of neurons in the layer
  • activation: One of 'relu', 'sigmoid', 'tanh'
  • layer: 'hidden' (default) or 'output'
  • input_size: Optional, only needed for first layer

Testing Monkey

You can run the provided test script:

python tests/test.py

Sample test scenarios include:

  • Predicting sums of two numbers
  • Predicting multiplication or XOR patterns
  • Testing different activation functions
  • Testing AttentionBlock on sequence data

Learning Tips for Beginners

  • Start with a single hidden layer and few neurons
  • Use small datasets (like sum of two numbers) for testing
  • Adjust learning_rate and epochs to see effect on convergence
  • Observe how activation functions change the output and training speed
  • Experiment with the AttentionBlock for sequence-based learning

Contributing

Monkey is beginner-friendly and open to contributions!

  • Experiment with new activation functions
  • Add utilities or visualization helpers
  • Improve training efficiency

Github Repo available at : 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.2.0.tar.gz (5.5 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.2.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for neural_monkey-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c168fa7bb211ddaf5175e5d666d11a1b07bdfb128d0bdb75e31d7087fa591096
MD5 684cb9949cc901ac79ac43fcff821e46
BLAKE2b-256 94c3f74aaba248a25cdd078251eb6f3c0953ebd69fe472cb2f14c27a26219659

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for neural_monkey-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 884324cb6558c25597e2f0e491adc3e18d3ebe4cd145498c350e2aada4ff0ffe
MD5 1875afb620fbdf60d42d8acaeaabc831
BLAKE2b-256 9b5854500fab6135029e241b2c7a514e8231b2d92ea01f31a81b338c13a09f8e

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