GithubHelp home page GithubHelp logo

iamwooki / singlelayerperceptron Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jakecowton/singlelayerperceptron

0.0 1.0 0.0 148 KB

An example of a python single layer perceptron

License: MIT License

Python 100.00%

singlelayerperceptron's Introduction

Single Layer Perceptron

SLPs are are neural networks that consist of only one neuron, the perceptron. It can take in an unlimited number of inputs and separate them linearly.

Here is a small bit of code from an assignment I'm working on that demonstrates how a single layer perceptron can be written to determine whether a set of RGB values are RED or BLUE.

Of course the G could just be ignored, but this code is just to show how a SLP can be used to get rid of noisy data and find the correct answer

Training Data

Here's some example training data

data = [#((R,G,B), CLASSIFICATION)
        [[0,0,255], BLUE],
        [[0, 0, 255], BLUE],
        [[0, 0, 192], BLUE],
        [[243, 80, 59], RED],
        [[255, 0, 77], RED],
        [[77, 93, 190], BLUE],
        [[255, 98, 89], RED],
        [[208, 0, 49], RED],
        [[67, 15, 210], BLUE],
        [[82, 117, 174], BLUE],
        [[168, 42, 89], RED],
        [[248, 80, 68], RED],
        [[128, 80, 255], BLUE],
        [[228, 105, 116], RED]
    ]

Normalising Data

In this project my normalise() function takes in each of the input values and turns them into a value between 0 and 1. To do that I multiply each of the values by 0.003921568 because 1 / 255 ~ 0.003921568.

To modify the function for your own use, change out 0.003921568 for 1/(max input value).

Increasing number of inputs

Theoretically, this can be done by passing the desired number of inputs into Perceptron() when you create it (I haven't tested this yet).

singlelayerperceptron's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.