Skip to main content

A neural network Framework

Project description

SJNET

This repository includes SJNET.py, which contains the Network and Layer classes.

These can be used to create and train custom neural network

Import SJNET

from SJNET import Network ,Layer

A new Network can be initialized by

# provide the dataset X and Y
# each element is Y must be an array [] , Y = [[y1..y1n],[y2..y2n]...[yN..yNn]]

network = Network(X=X,Y=Y,learningRate=0.0002,epoch=1000,errorThresh=3)

Declare or initialize layers with its coresponding arguments

  • neuronCount : number of neurons required in the layer

  • position : position of layer in network

    • Note : (1 for input layer and -1 for output layer)
  • activation : required activation function , avilable("linear","relu")

#Note: position must be (1 for input layer and -1 for output layer)
inputLayer = Layer(neuronCount=2,position=1)
hidden = Layer(neuronCount=10,position=2,activation="linear")
hidden2 = Layer(neuronCount=4,position=3,activation="linear")
output = Layer(neuronCount=1,position=-1,activation="linear")

Add declared layers into the network

#add them in order (inputLayer->first , outputLayer->last)
network.add(layer=inputLayer)
network.add(layer=hidden)
network.add(layer=hidden2)
network.add(layer=output)

Compile or initilise the network setup

network.compile()

Train the model

network.Train()

Save the model

# saved as json
network.save(name="testModel")

Load the model

Model = {}
with open('./savedmodels/testModel.json', 'r') as file:
    Model = json.load(file)

#Loads the  network topology weights and biases 
network.loadNetwork(network=Model)

predict with model

pred_val = network.predict(inputvals=[3.1, 2.5])

How to train and save a model -> Training_and_Saving_Model.py

How to load and use the model -> Loading_Pre_Trained_Model.py

It uses stochastic gradient descent, just in case you are curious.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SJNET-1.0.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

SJNET-1.0.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file SJNET-1.0.0.tar.gz.

File metadata

  • Download URL: SJNET-1.0.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for SJNET-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c3fbbacd1d44535701004ac9e54183f2cc5b5d677363e79df56d000297be6b41
MD5 4790c6573198db42ed5426568b262eac
BLAKE2b-256 7423ed2df3b90070b850907e9581eca9ff5d2d913e1876bdcf78389a1adfbc09

See more details on using hashes here.

File details

Details for the file SJNET-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: SJNET-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for SJNET-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85ad7331fba6c11a6c14a33e17edfbf06b987d0eb1195325b348c068752c5e57
MD5 5d3f9827784e08366a243d71a39c5460
BLAKE2b-256 929f448fecf55bb828d4d9083977bf9e99aabb8171bfbd0108fadfe9e8e9ba52

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page