Skip to main content

Multilayered Perceptron NN light weight, make, train, test models

Project description

pip install sidSimpleNN

you can also visit my website for testing manual Digit and Letters Recognition https://siddhantofficialsidsimpl-868fa.web.app you can also train your model through this lib and upload your weights and bias json file to this site to test your figures(letter, shape etc) recognition

In data folder Can be downloaded from http://yann.lecun.com/exdb/mnist/

net.chosenLoss='CE' ## for classification use CE and for regression use MSE net.chosenActivation='relu' ## can choose from relu, tanh, sigmoid net.applySoftmax=True ## for classification make this true, gives output as probability net.applyRegularization=False ## apply L2 regularization net.calcLoss=False ## should calculate loss net.otherImplementation=False ## for non batch wise training net.saveWeightsBiasJSON() ##save WB file for using it in my website net.save() ## to save model net.load() ## to load the model you need to have same name as saved model net.showModel() ## details of model net.changeActivation() ## to apply choosen activation net.lossGraph() ## to display loss vs iter graph net.feedforward(input) ## to get the last layer output

from sidSimpleNN import mainTrain

mainTrain.run()

if data,mnist folder dont get made automatically then manualy download from MNIST dataset and place in datafolder

if above code doesnt work then test with this

import numpy as np import mnist import sidSimpleNN.myNN as myNN

def run():

# load data
num_classes = 10
train_images = mnist.train_images() #[60000, 28, 28]
train_labels = mnist.train_labels()
test_images = mnist.test_images()
test_labels = mnist.test_labels()

# print("Training...")

# # data processing
X_train = train_images.reshape(train_images.shape[0], train_images.shape[1]*train_images.shape[2]).astype('float32') #flatten 28x28 to 784x1 vectors, [60000, 784]
x_train = X_train / 255 #normalization
y_train = np.eye(num_classes)[train_labels] #convert label to one-hot

X_test = test_images.reshape(test_images.shape[0], test_images.shape[1]*test_images.shape[2]).astype('float32') #flatten 28x28 to 784x1 vectors, [60000, 784]
x_test = X_test / 255 #normalization
y_test = test_labels

np.random.seed(1)

net = myNN.Network(
             num_nodes_in_layers = [784, 10,20, 10], 
             batch = 1,
             epochs = 6,
             learning_rate = 0.001, 
             weights_file=None,
             chosenActivation='tanh'
             # name='tempnet3'
             # weightsAndBias_file = 'digitRecog',
             # includeWeightsBias=True

         )


print('before training , testing with test dataset')
# net.chosenLoss='CE'
# net.applySoftmax=True
# net.applyRegularization=False
# net.regularizationConst=0.01
# net.calcLoss=False
# net.saveWeightsBiasJSON()
message=net.test(x_test, y_test)


net.train(x_train, y_train)
net.save()
net.lossGraph()
print('before training , testing with test dataset')
print(message)

print("after training")
net.test(x_test, y_test)
net.showModel()

if name=='main': run()

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

sidSimpleNN-0.2.8.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

sidSimpleNN-0.2.8-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file sidSimpleNN-0.2.8.tar.gz.

File metadata

  • Download URL: sidSimpleNN-0.2.8.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.24.0 CPython/3.7.3

File hashes

Hashes for sidSimpleNN-0.2.8.tar.gz
Algorithm Hash digest
SHA256 5839a9594b66ff892c94771a6531e2ad259821bc04bd803e2f6e88edc601fa2e
MD5 c0e7af2059094bcf875dbb2ff8e78b4b
BLAKE2b-256 732798a2f119a00d20073a6a01d5b1750e17aa0f913e367400a4430d7a8605ad

See more details on using hashes here.

File details

Details for the file sidSimpleNN-0.2.8-py3-none-any.whl.

File metadata

  • Download URL: sidSimpleNN-0.2.8-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.24.0 CPython/3.7.3

File hashes

Hashes for sidSimpleNN-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 6b0bf0387d852211dff17731c980f21a771a4552ad0bdbfe8c701c86ba6b4276
MD5 aa8358e7d1832c4090be27ff582be57d
BLAKE2b-256 82190af8620245a81cf3f7681762b3c998867f29f7d04667af1f5403bfefd573

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