Skip to main content
Build Status

Multilayer Perceptron in Python

Python implementation of multilayer perceptron neural network from scratch.

Minimal neural network class with regularization using scipy minimize. Contains clear pydoc for learners to better understand each stage in the neural network.

Requirements

  • Python 3.4 (tested)

Goal

To provide an example of a simple MLP for educational purpose.

Code sample

Predicting outcome of AND logic gate:
X = 000, 001, 010, 011, 100, 101, 110, 111

y = 0,0,0,0,0,0,1

Data we want to predict: p = 011, 111, 000, 010, 111 Expected results are: 0, 1, 0, 0, 1

import numpy as np
from mlperceptron.mlperceptron import NeuralNetwork

X = np.matrix(
    '0 0 0;0 0 1;0 1 0;0 1 1;1 0 0;1 0 1;1 1 0;1 1 1')
y = np.matrix('0;0;0;0;0;0;0;1')
n = NeuralNetwork((5,5,))

g = n.train(X, y, 0.01, show_cost=True)
y_pred = n.predict(np.matrix('0 1 1;1 1 1;0 0 0;0 1 0;1 1 1'), g)

print(y_pred)
print(n.accuracy(y_pred, np.matrix('0;1;0;0;1')))

Contributors

Metadata

Release files for mlperceptron 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mlperceptron 0.3
File Size Uploaded Provenance Actions
mlperceptron-0.3.tar.gz 5.7 kB Without provenance Details for mlperceptron-0.3.tar.gz

Release files / mlperceptron-0.3.tar.gz

Download URL mlperceptron-0.3.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
593d8ab73b20649d27b1eef061d0f49cc6b876b8cdf40a4fe81cd1c2cb6a68f7
BLAKE2b-256 checksum
How to use checksums
18f01542ea0e518eab35644c4b500a962463e9083275f4033d352709a77174cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for mlperceptron 0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page