Skip to content
Neural Network lib in Python
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
Data.py
Grapher.py
LICENSE
MNIST_demo.py
NN.py
README.md
demo.py
graphics_pygame.py
graphics_qt.py
mathlib.py
requirements.txt
view.gif

README.md

NN.py

Neural Network lib in Python

NN.py - Main Neural Network Class

Grapher.py - Data visualization Class

Data.py - Dataset Class

Graphics

graphics_pygame.py - Pygame Graphics Class

graphics_qt.py - QT Graphics Class

Install Dependencies

pip install -r requirements.txt

Example Code

from NN import *
from Data import *

data = Data()
data.generateXORData(1000, 0.2)  #generate XOR dataset with 1000 points

testData = Data()
testData.generateXORData(50, 0.2) #generate another XOR dataset with 50 points, this will be used for validation

nn = NN(2,4,3,1) #2 input neurons, 4 neurons in first hidden layer, 3 in second hidden layer and 1 in output layer
nn.activationFunction = "sigmoid" #use the sigmoid function as the activation function
nn.learningRate = 0.03
    
for i in range(1000): #500 epochs of training
    if(i%10 == 0): #print error rate every 10 epochs
        error = nn.evaluate(testData)
        print("epoch %d: %f"%(i,error[0]))
    nn.minibatch(data,10) #train model with minibatches of 10

View

You can’t perform that action at this time.