A high-performance and lightweight neural network library for Python.
Installation
pip install ncxlib
Quick Start
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 # External imports 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)
Please ⭐ our repo to support our work!