Skip to main content

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

Release files for ncxlib 0.3.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ncxlib 0.3.5
File Size Uploaded
ncxlib-0.3.5.tar.gz 25.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ncxlib 0.3.5
File Interpreter ABI Platform
ncxlib-0.3.5-py3-none-any.whl Python 3 none any Details

Total release size: 69.6 kB

Release files / ncxlib-0.3.5.tar.gz

Download URL ncxlib-0.3.5.tar.gz
Size 25.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6883aa8e531743f44881b46550f8717cd28464b845e6540a626cc289f4fef374
BLAKE2b-256 checksum
How to use checksums
968b782f1d90bcfd34f5112a9759db2ff4a24422bc1a29e44f54fc4539ffb942
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.10.7 Darwin/23.5.0

Release files / ncxlib-0.3.5-py3-none-any.whl

Download URL ncxlib-0.3.5-py3-none-any.whl
Size 43.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
79404c68b1af48fd6ce72b66cc8ae78b64200808b77114055a299694530331f8
BLAKE2b-256 checksum
How to use checksums
ec448bc8d33c9e124a41925f488eb4866b04e112042c9f5e6c7a50ba54f998cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.10.7 Darwin/23.5.0

Release history Release notifications | RSS feed

This release

0.3.5 This release

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page