Skip to main content

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 imports
import numpy as np

# Util imports
from ncxlib import generators, dataloaders, optimizers, losses, activations
from ncxlib.util import train_test_split

# Neural network imports
from ncxlib.models.neuralnetwork import NeuralNetwork, FullyConnectedLayer
from ncxlib.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)
results = model.evaluate(X_test, y_test, metrics=['classification', 'roc'])

Contributing

Thank you for your interest in contributing to the ncxlib library for Neural Network development. We are thrilled you are considering contributing to our project.

How to Contribute

  • Take a look at the list of immediate contributions needed listed under the issues
  • Look for areas around the repository with comments marked #TODO. If you find one, feel free to create an issue and get approval before starting the work.
  • Any suggestions or feedback - please create an issue.
  • Open a Pull Request with your issue and the team will review and approve/deny or provide comments on the PR.

License

This project is licensed under the 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

ncxlib-0.3.4.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ncxlib-0.3.4-py3-none-any.whl (43.9 kB view details)

Uploaded Python 3

File details

Details for the file ncxlib-0.3.4.tar.gz.

File metadata

  • Download URL: ncxlib-0.3.4.tar.gz
  • Upload date:
  • Size: 25.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.7 Darwin/23.5.0

File hashes

Hashes for ncxlib-0.3.4.tar.gz
Algorithm Hash digest
SHA256 adf871268163f4d65dd6fb07939747cfacda1f43baa450699eb513942db9e3f2
MD5 c9408b429ab42f86d7d12d309f324349
BLAKE2b-256 755ef285e74f9b4ed033fd5d1ebefaf4a9e625180df86227500350a5d5da0129

See more details on using hashes here.

File details

Details for the file ncxlib-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: ncxlib-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 43.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.7 Darwin/23.5.0

File hashes

Hashes for ncxlib-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 acb3150f31a16767ee44bbba972a77d6c9284750d2c7d84f4d5761bd9a6ac88a
MD5 6e6cba6f7e76ab52f146e797a3f9ca7f
BLAKE2b-256 64e6d42debfe8d56d77c4ad2f6cdf8001e688d8b61f961652a40c9711743decb

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