Neural Network Creator
Create and generate Neural Networks without using heavy modules like Keras
Table of contents
Example Code
>>> from neural import Neural
>>> nodes = [[0,0], # 2 Input Neurons
>>> [0,0,0,0,0,0], # 6 Hidden Neurons (Hidden Layer #1)
>>> [0,0,0,0,0,0], # 6 Hidden Neurons (Hidden Layer #2)
>>> [0,0,0,0]] # 4 Output Neurons
>>> n = Neural(nodes) # make Neural Object, __init__ requires nodes
>>> n.shuffle() # shuffle all weights to be random (using random module)
>>> print(n.input([1,2,3,4]) # print out output neurons with input list
>>> n.show() # visualize network using Tkinter
>>> n.save("my_neural_network.txt") # save network to file_name.txt
Setup
-
Download Python File/s
-
Installing them as Module using pip
Tutorial: http://www.discoversdk.com/blog/how-to-create-a-new-python-module
Exporting as a Public Module soon!
- Use as Class in your Project
- Copy the File/s into your Project Folder
- Import the Class using
from neural import Neural- Create Neural Object using
yourObj = Neural(nodes) # seeTutorialfor closer description
Tutorial
# setup network nodes with __init__(self, nodes)
# nodes has to be a two dimensional array, containing floats/integers, representing nodes
> nodes = [[0,0],[0,0,0,0],[0,0,0]] # 2 input neurons, 1 hidden layer containing 4 neurons, 3 output neurons
> network1 = Neural(nodes) # create Neural Object
# input values using
> network1.input([1,2]) # pass 1D list, len must be equal to number of input neurons
# show network (with Tkinter module, located in neuraldisplay.py) using
> network1.show() # opens 1400px * 700px window
> network1.show(size = [x,y]) # modify window size
# update every weight to be random from -1 to 1
> network1.shuffle() # uses random module
# update every weight to be in range of +- amount of given weights (of another neural network)
> network1.shuffle_amount(amount) # amount will be devided by 100
> network1.shuffle_amount(50) # to achieve a learning rate of 0.5
# save network to file_name.txt to be loaded in later
> network1.save(file_name) # file_name must be string ending in .txt (located in same directory)
# load network from file_name.txt to current network
> network1.load(file_name) # file_name must be string ending in .txt (located in same directory)
Accessing the Network
# Access Network List using
> network1.nodes
# Access individual layers using
> network1.nodes[layer_number]
# Access individual nodes dictionary using
> network1.nodes[layer_number][position_in_layer]
# Access output value of an individual node using
> network1.nodes[layer_number][position_in_layer]["output"]
# Access list of weights of an individual node using
> network1.nodes[layer_number][position_in_layer]["weights"]
Training using Backpropagation
# setup network nodes with __init__(self, nodes)
# nodes has to be a two dimensional array, containing floats/integers, representing nodes
> nodes = [[0,0],[0,0,0,0],[0,0]] # 2 input neurons, 1 hidden layer containing 4 neurons, 2 output neurons
> network1 = Neural(nodes) # create Neural Object
# load the training data using (see Training Data Formating)
> inputs, outputs = network1.load_training_data("training_example.txt") # must be .txt file in the same directory
# train the network using
> network1.train(l_rate, # learning rate (e.g. 0.2)
cycles, # how many cycles (epochs) the network will train through (e.g. 1000)
inputs, # inputs set from loading the training data
outputs, # outputs set from loading the training data
print_status=True) # (optional) print progress into console (Default is False)
# get the total score using (how many of your training examples it passes)
> score, max_score = network1.get_total_score(inputs, outputs) # set score and max_score
> print(f"{score}/{max_score}") # python 3 (f-strings)
Training Data Formatting
Training Data to be read must be located in yourfilename.txt file
Inputs must be seperated by Comma (e.g.1,2,3,4)
Outputs must be seperated by Comma (e.g.0,1,0)
Inputs and Outputs must be seperated by equal sign (e.g.1,2,3,4=0,1,0) ending in line break ("\n")
see "training_example.txt"
Screenshots
Status
Project is IN PROGRESS
todo list in PROJECT: Neural Network maker
https://github.com/noel-friedrich/neural/projects/1
Credits
Training Algorithm Code was heavily inspired by https://machinelearningmastery.com/implement-backpropagation-algorithm-scratch-python/
Metadata
Release files for noelnetwork 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| noelnetwork-1.0.3.tar.gz | 5.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| noelnetwork-1.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.9 kB
Release files / noelnetwork-1.0.3.tar.gz
| Download URL | noelnetwork-1.0.3.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ba5b8d3c8cb9603f7e93d400e9780b9ad2fb3203ae016dbdbf9f72bd7cfa48a6
|
|
BLAKE2b-256 checksum How to use checksums |
2d55258d31049b8266a9269191ed3043078df0c2db4719b38a8559d2570d5f85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.7.9
|
Release files / noelnetwork-1.0.3-py3-none-any.whl
| Download URL | noelnetwork-1.0.3-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5576b20ada49c27694bd3a2ae6b2a1459071064ff3d9aff8f044b394aabf400e
|
|
BLAKE2b-256 checksum How to use checksums |
f146858a0975251c41a944801f7ea036325f1e0e7aae4013ae628f140a3c2ae7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.7.9
|