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

# download SJNET.py then continue
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-0.1.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

SJNET-0.1.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for SJNET-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0eeb6b468005df46789586cddbf78c320e2c7f671c94d9edda7f91a721fa6bf9
MD5 d8f09c7e5e63b9fc4abb1e0002be406c
BLAKE2b-256 f868497db2c5533124b0aa07b252e7e451d4b15497038df088661557215c819a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for SJNET-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e5fbd3f474da689cb714df335a341f73df16163c7c186bdf654bd4cafa693b21
MD5 2a718e19e5ad51d627c9efa932e971c8
BLAKE2b-256 65f2ca08dbc36dc9abaa6940f9d9688885493c890fc70003614f214b07afff0c

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