Neural Network lib for ncxlib
Project description
NCxLib: A Lightweight Neural Network Library in Python
ncxlib is a lightweight and easy-to-use neural network library built in Python. It provides a simple API for constructing and training neural networks, along with tools for data preprocessing and generation.
Features
- Modular Design: Easily build custom neural networks by combining different layers, activation functions, and loss functions.
- Data Handling: Includes data loaders for CSV and image data, with preprocessing capabilities like scaling and grayscaling.
- Training and Evaluation: Train your networks with various optimization algorithms and evaluate their performance.
- Extensible: Add your own custom layers, activations, and loss functions to expand the library's functionality.
Installation
pip install ncxlib
Getting Started
Here's a quick example of how to use ncxlib to create and train a simple neural network:
# External imporst
import numpy as np
# Util imports
from ncxlib import generators, dataloaders
from ncxlib.util import train_test_split
# Neural network imports
from ncxlib.neuralnetwork import optimizers, losses
from ncxlib.preprocessing import MinMaxScaler
from ncxlib.neuralnetwork import NeuralNetwork, FullyConnectedLayer
from ncxlib.neuralnetwork import activations
from ncxlib.neuralnetwork.initializers import HeNormal, Zero
# ------- Generate some data using generators -------
generators.generate_training_data(to_csv=True)
# ------- Load data from generated csv and split it into train and test -------
loader = dataloaders.CSVDataLoader("training_data.csv")
X, y = loader.get_data()
X_train, X_test, y_train, y_test = train_test_split(X, y)
# ------- Configure model layers -------
model = NeuralNetwork([
FullyConnectedLayer(
n_neurons=3,
activation=activations.ReLU,
optimizer=optimizers.Adam(beta_1=0.9, beta_2=0.999, epsilon=1e-07),
name="first_hidden",
weights_initializer=HeNormal(),
bias_initializer=Zero()
),
FullyConnectedLayer(
n_neurons=5,
activation=activations.ReLU,
optimizer=optimizers.SGDMomentum(momentum = 0.9),
name="second_hidden",
initializer=HeNormal(),
),
FullyConnectedLayer(
n_neurons=2,
activation=activations.Sigmoid,
optimizer=optimizers.RMSProp(decay_rate = 0.8)
)
],
loss_fn=losses.BinaryCrossEntropy
)
# ------- Train model and evaluate accuracy -------
model.train(X_train, y_train, epochs=20, learning_rate=0.01)
model.evaluate(X_test, y_test)
License
This project is licensed under the MIT License
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
ncxlib-0.2.4.tar.gz
(17.9 kB
view details)
Built Distribution
ncxlib-0.2.4-py3-none-any.whl
(32.7 kB
view details)
File details
Details for the file ncxlib-0.2.4.tar.gz
.
File metadata
- Download URL: ncxlib-0.2.4.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.4 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 676424f66a9e060b4dafe1a7270ecc222fffe1e2168cb4c3c44b5e3997a9db47 |
|
MD5 | 3c74874edd9421146ddcf5e5d36987f7 |
|
BLAKE2b-256 | eb90a306da4cab9650c763ff4c6c9e5c50ba94c6fdd78d772ec9a6768bf0535b |
File details
Details for the file ncxlib-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: ncxlib-0.2.4-py3-none-any.whl
- Upload date:
- Size: 32.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.4 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31616d8d14695da5f907a49c95d5d50db31c441da7ef6d4f4deb2c8e59ecbca3 |
|
MD5 | fb55279fd038b12201ec9c1a2ef311b8 |
|
BLAKE2b-256 | 4d150aadc5d447c5858a20de293f5c6e6d1814a448001a454fe1fc4a892e706a |