Skip to main content

A package optimised for building small neural networks.

Project description

SnoScience

A package optimised for building small neural networks.

The MNIST dataset has been used for validation. Each network is trained by using 64 samples from this dataset per epoch for 200 epochs. As can be seen from the graph, use Tensorflow or equivalent for networks with more than 3 layers (n>3) and/or more than 20 neurons per layer. SnoScience networks with one (n=2) or no hidden layers (n=1) are extremely fast.

Installation

To install the SnoScience package, run the following command:

pip install snoscience

Alternatively, install the package via your IDE.

Usage

To get started with the SnoScience package, use the code example below:

from snoscience.networks import NeuralNetwork
from snoscience.metrics import calculate_mse, calculate_accuracy

# Define your dataset here.
x_train, y_train, x_test, y_test = [], [], [], []

# Create model with 1 hidden layer and 1 output layer (n=2).
model = NeuralNetwork(inputs=X, loss="MSE", optimiser="SGD")  # X features per sample
model.add_layer(neurons=2, activation="sigmoid")
model.add_layer(neurons=Y, activation="sigmoid")  # Y outputs per sample

# Define optimizer hyperparameters.
rate = 0.01

# Train model with training updates.
model.train(x=x_train, y=y_train, epochs=1000, samples=32, rate=rate, log=True)
# Or without.
model.train(x=x_train, y=y_train, epochs=1000, samples=32, rate=rate, log=False)

# Make predictions (classification).
y_calc = model.predict(x=x_test, classify=True)
 
# Make predictions (regression).
y_calc = model.predict(x=x_test, classify=False)

# Calculate performance.
mse = calculate_mse(calc=y_calc, true=y_test)
accuracy = calculate_accuracy(calc=y_calc, true=y_test)

Features

SnoScience.networks module

  1. The user is able to create a neural network capable of being trained and making predictions:
    1. this network is able to process an arbitrary number of inputs.
    2. this network can consist of an arbitrary number of layers.
    3. each layer in this network can consist of an arbitrary number of neurons.
  2. The neural network supports the following activation functions:
    1. sigmoid.
  3. The neural network supports the following loss functions:
    1. mean squared error (MSE).
  4. The neural network supports the following optimisers:
    1. stochastic gradient descent (SGD).
  5. The user can train the neural network with a single command:
    1. all inputs are checked for validity before the training proceeds.
  6. The user can let the network make predictions with a single command:
    1. all inputs are checked for validity before predictions are given.
    2. these predictions can be regressions of an arbitrary size.
    3. these predictions can be classifications of an arbitrary size.

SnoScience.metrics module

  1. The user is able to calculate the mean squared error of a regression.
  2. The user is able to calculate the accuracy of a classification.

Changelog

v1.1.0

  • Build changed from Setuptools to Poetry.
  • Revision of project structure.
  • Revision of documentation.

v1.0.1

  • Revision of project structure.
  • Revision of documentation.

v1.0.0

  • SnoScience.networks features 1 through 6 added.
  • SnoScience.metrics features 1 and 2 added.

v0.1.0

  • Initial release.

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

snoscience-1.1.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

snoscience-1.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file snoscience-1.1.0.tar.gz.

File metadata

  • Download URL: snoscience-1.1.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.9.13 Windows/10

File hashes

Hashes for snoscience-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e35ef6f9a06b99665f5fa13cae32d2aafd0ba8e807e8ca8383eecaf560b00912
MD5 cb101b2645a8f09c16bcf41e051d93ef
BLAKE2b-256 7578a38c10fdbb36718d20f859e342f0a84b5b2bca1ff3f3a4cef5055559fe01

See more details on using hashes here.

File details

Details for the file snoscience-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: snoscience-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.9.13 Windows/10

File hashes

Hashes for snoscience-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d3e4900511acb85a172792e1d12fb692193c54d1918d08045cc541762b4f2f2
MD5 6e4d7eabed014cc0bceeb130ba680016
BLAKE2b-256 35d9583e9343dd0073e14070f673a346e6242b0911bebfe131df5c65ad0028f7

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