Skip to main content

My custom neural net architecture written in Python to practice my ML skills.

Project description

Slowest-Neural-Net-in-the-West

My custom neural net architecture written in Python to practice my ML skills.

Install

Make a new Python virtual environment (version >= 3.6). Install this project with pip. In terminal, run

pip3 install snnw

Download MNIST dataset

Open a new Python shell or Jupyter Notebook and run

import snnw

Set raw_dir = the directory where you want to save the MNIST raw data files. Run

snnw.dataset.mnist.download.raw(raw_dir)

Set png_dir = the directory where you want to save the MNIST .png images and path text files. Run

snnw.dataset.mnist.convert.raw_to_png(raw_dir, png_dir)

Set npy_dir = the directory where you want to save the MNIST .npy image and label numpy arrays. Run

snnw.dataset.mnist.convert.png_to_npy(png_dir, npy_dir)

Get model config

Set config_path = the path to where you want to save the training/testing model's config file. Run

snnw.nn.config.get(config_path, 1) or snnw.nn.config.get(config_path, 2)

to write sample config file 1 or 2 to config_path, or write your own config file and place it where config_path points to.

If you write a custom config file, make sure that it follows the given format to prevent parsing errors!

Train model

Set model_dir = the directory where the trained model's weights and biases will be stored.

Set train_image_path = the path to where the .npy file for the training image arrays are located. This file should be located inside the npy_dir you specified earlier.

Set train_label_path = the path to where the .npy file for the training label arrays are located. This file should be located inside the npy_dir you specified earlier.

Set steps = the number of training steps you would like to train for. The default is 60,000.

Set learning_rate = the learning rate you would like to train with. The default is 5e-4.

Run snnw.run.train(model_dir, config_path, train_image_path, train_label_path, steps, learning_rate).

Note: if you get a NaN error or "not a probability array" error, then you probably have a vanishing or exploding gradient problem. To fix this, try adjusting the learning rate. The default learning rate and number of steps included have been tested to work with both included models.

Test model

Set test_image_path = the path to where the .npy file for the training image arrays are located. This file should be located inside the npy_dir you specified earlier.

Set test_label_path = the path to where the .npy file for the training label arrays are located. This file should be located inside the npy_dir you specified earlier.

Run snnw.run.evaluate(model_dir, config_path, test_image_path, test_label_path).

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

snnw-0.2.8.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

snnw-0.2.8-py2.py3-none-any.whl (11.6 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: snnw-0.2.8.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9

File hashes

Hashes for snnw-0.2.8.tar.gz
Algorithm Hash digest
SHA256 28f1b8e2ce83223986f412e699a69fd3b83bff9c38ea70a0f2688f5f506e2ab6
MD5 7db2ad434c1280d413889c20dc388faf
BLAKE2b-256 4c2fa4e51c5b37dedb7453f03d45144d748eeaf8fd49eb40eaefeaed1f522799

See more details on using hashes here.

File details

Details for the file snnw-0.2.8-py2.py3-none-any.whl.

File metadata

  • Download URL: snnw-0.2.8-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9

File hashes

Hashes for snnw-0.2.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ce05c3dcaa69eb505b3253b74167ceb3433534c28f6f1d0b38d9d206c42ec4ef
MD5 26088aa2dede2885a2fffb88cd2b266c
BLAKE2b-256 e5b3b4fd0c14c3720bf6489ab4fe4b2eed1173d2080e71214b8b94d54ffbbd68

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