GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Capsar/python-neural-network: A simple fully connected feed forward neural network written in python from scratch using numpy & optimized using numba. It is possible to have multiple hidden layers, change amount of neurons per layer & have a different activation function per layer.

BranchesTags
Open more actions menu

Latest commit

 

History

22 Commits
22 Commits

Folders and files

NameName
Last commit message
Last commit date
data
data
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
main.py
main.py
 
 
numba_neural_network.py
numba_neural_network.py
 
 
prepare_data.py
prepare_data.py
 
 
z_helper.py
z_helper.py
 
 

Repository files navigation

python-neural-network

A simple fully connected feed forward neural network written in python from scratch using numpy. It is possible to have multiple hidden layers, change the amount of neurons per layer & have a different activation function per layer.

Written in python 3.7.7

If you have any tips on how to imporve performace, let me know!

import numpy as np
from numba.experimental import jitclass
from numba import types, typed
data_input = np.load("data/ci_inputs.npy")
data_output = np.load("data/ci_outputs.npy")

print("Begin compiling!")
begin_time = time.time_ns()
compile_nn = make_neural_network(layer_sizes=[data_input.shape[1], data_output.shape[1]], layer_activations=["sigmoid"])
compile_nn.train(data_input[:1], data_output[:1], data_input[1: 2], data_output[1: 2])
end_time = time.time_ns()
print("Compile time:", (end_time-begin_time) / 1e9)

for i in range(10):

    random_seed = np.random.randint(10, 1010)
    np.random.seed(random_seed)

    train_input, validate_input, test_input = h.kfold(4, data_input, random_seed)
    train_output, validate_output, test_output = h.kfold(4, data_output, random_seed)

    nn = make_neural_network(layer_sizes=[train_input.shape[1], 20, train_output.shape[1]], layer_activations=["sigmoid", "sigmoid"])

    begin_time = time.time_ns()
    epochs, current_mse = nn.train(train_input, train_output, validate_input, validate_output)
    end_time = time.time_ns()

    train_mse = nn.calculate_MSE(train_input, train_output)
    test_mse = nn.calculate_MSE(test_input, test_output)

    accuracy_test = nn.evaluate(test_input, test_output)
    print("Seed:", random_seed, "Epochs:", epochs, "Time:", (end_time-begin_time)/1e9, "Accuracy:", accuracy_test, "Tr:", train_mse, "V:", current_mse, "T:", test_mse)

About

A simple fully connected feed forward neural network written in python from scratch using numpy & optimized using numba. It is possible to have multiple hidden layers, change amount of neurons per layer & have a different activation function per layer.

Topics

c-codec-plus-plusneural-networkneuralnetworknumbanumpynumpy-neural-networknumpy-numbapythonpython-numbapython-numpy

Resources

Readme
Activity

Stars

3 stars

Watchers

2 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.