A simple and flexible neural network package
Project description
Nerdron
This is a Python package that provides a simple and flexible neural network implementation, with support for customizable layer configurations, activation functions, and training parameters.
Features
- Multi-layer Neural Network: The
NeuralNetworkclass allows you to create neural networks with an arbitrary number of layers. - Customizable Activation Functions: The
Activationclass provides common activation functions like sigmoid, tanh, ReLU, and softmax, which can be used in the neural network layers. - Backpropagation-based Training: The
NeuralNetworkclass implements the backpropagation algorithm for training the neural network on input-output pairs. - User-friendly API: The package provides a simple and intuitive API, making it easy to integrate into your projects.
Installation
To install the neural network package, you can use pip:
pip install nerdron==0.3.1
Usage
Creating a Neural Network
To create a neural network, you can use the NeuralNetwork class. The constructor takes the following arguments:
layers: A tuple of integers representing the number of neurons in each layer, including the input and output layers.activation: (optional) A callable that represents the activation function to be used in the layers. Defaults toActivation.SIGMOID.learning_rate: (optional) The learning rate to be used during training. Defaults to 0.01.epochs: (optional) The number of training epochs. Defaults to 1000.
Example:
from nerdron import NeuralNetwork, Activation
# Create a neural network with 2 input neurons, 2 hidden neurons, and 1 output neuron
nn = NeuralNetwork(layers=(2, 2, 1), activation=Activation.SIGMOID, learning_rate=0.1, epochs=1000)
Training the Neural Network
To train the neural network, you can use the train method, which takes the input data X and the target output y as arguments.
Example:
# Example data
X = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
y = np.array([0, 1, 1, 1])
# Train the neural network
nn.train(X, y)
Making Predictions
After training the neural network, you can use the forward method to make predictions on new input data.
Example:
# Make predictions
print(nn.forward(np.array([0, 1]))) # Output: ~0.9
print(nn.forward(np.array([1, 0]))) # Output: ~0.9
print(nn.forward(np.array([0, 0]))) # Output: ~0.1
print(nn.forward(np.array([1, 1]))) # Output: ~0.9
Modules
activation.py
This module defines the Activation class, which provides common activation functions like sigmoid, tanh, ReLU, and softmax.
layer.py
This module defines the Layer class, which represents a single layer in the neural network. Each layer has an activation function, weights, and biases.
network.py
This module defines the NeuralNetwork class, which represents the entire neural network. It handles the forward propagation, backpropagation, and updating of the weights and biases.
Contribution
If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the GitHub repository.
[!NOTE]
Under Development.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nerdron-0.3.1.tar.gz.
File metadata
- Download URL: nerdron-0.3.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d78d7009a3b152675a0a6143e048bbfa8b9d90329dc437da72044efcec81a2a3
|
|
| MD5 |
361cb45252207dcfcaa77cec9719af1f
|
|
| BLAKE2b-256 |
f299e3edf7f135bdb198b7eb41fb13fa0f5497ea01600e80b4fa8bddc70cff37
|
File details
Details for the file nerdron-0.3.1-py3-none-any.whl.
File metadata
- Download URL: nerdron-0.3.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fa95953a51f24bd689a64b2e6d120d012068d968356132851a97722553cf1bf
|
|
| MD5 |
d68afd61a89f6843056a69de9699985a
|
|
| BLAKE2b-256 |
cdaeaf85824876c1cb80f13b57c27ab1f7badf653e0c5a288a58440714ce9740
|