Basics of Perceptron Foundation

Introduction

When I was wondering what to study in the future, I thought that I should acquire AI-related knowledge. I will keep the learning history in Qiita. In the same way, I hope it helps those who are trying to learn machine learning.

environment

OS:windows 10 python3

About Perceptron

Basic shape

The perceptron receives multiple signals as input values and outputs them to one signal. The image is like creating a signal flow and transmitting information to the output destination. It can be said that the signal of Perceptron is "0" or "1" with two choices of flowing / not flowing. The figure below shows an example of a 2-input 1-output perceptron.

2入力1出力パーセプトロン.jpg

x_1,x_2 =input signal\\
w_1,w_2 =weight\\
y=Output signal

Each time the input signal is sent to a neuron, it is multiplied by a unique weight. If the sum exceeds a certain limit value, 1 is output. This is called ** neurons firing **. This limit value will be used as the threshold value in the future. (Lower formula)

\theta =Threshold

The above can be summarized and expressed in the formula below.

f(x) = \left\{
\begin{array}{ll}
1 & (w1x1 + w2x2 \, > \, \theta) \\
0 & (w1x1 + w2x2 \, \leqq \, \theta)
\end{array}
\right.

Perceptron has a weight for each of multiple input signals, and it can be seen that the larger the weight, the more important information.

bias

Bias is a parameter that adjusts the ease of firing of neurons. (Adjustment of the degree of output "1") The figure and formula are displayed below.

バイアスを図に表す例.jpg

\Replace theta with b\\ 
f(x) = \left\{
\begin{array}{ll}
1 & (w1x1 + w2x2 \, > \, b) \\
0 & (w1x1 + w2x2 \, \leqq \, b)
\end{array}
\right.
\\Transition\\ 
f(x) = \left\{
\begin{array}{ll}
1 & (b+w1x1 + w2x2 \, > \, 0) \\
0 & (b+w1x1 + w2x2 \, \leqq \, 0)
\end{array}
\right.

As the above equation shows, does the sum of the input signal, the weighted value, and the bias exceed 0? You can see that the output value can be controlled based on this.

Try to implement

I'll set the weights and biases appropriately and run it in Python.

1-1perceptron_and_bias.py


# coding: utf-8
import numpy as np

#Input value
x=np.array([0,1])

#weight
w = np.array([0.5, 0.5])

#Input value
b = -0.7

print(x * w)
print(np.sum(x * w)+b)

Execution result


[0.  0.5]
-0.19999999999999996

With bias, I was able to set the result below 0.

Summary

I think it will be a good output if you remember it while running it in Python. In the area of machine learning, we will continue to update it because it is not the tip of the iceberg.

Recommended Posts

Basics of Perceptron Foundation
Basics of python ①
Basics of Python scraping basics
# 4 [python] Basics of functions
Basics of network programs?
Basics of regression analysis
Basics of python: Output
Basics of Machine Learning (Notes)
python: Basics of using scikit-learn ①
Supervised learning 1 Basics of supervised learning (classification)
XPath Basics (1) -Basic Concept of XPath
Basics of Python × GIS (Part 1)
Basics of Python x GIS (Part 3)
Paiza Python Primer 5: Basics of Dictionaries
Read "Basics of Quantum Annealing" Day 5
Getting Started with Python Basics of Python
Explanation and implementation of simple perceptron
[Must-see for beginners] Basics of Linux
Topic extraction of Japanese text 1 Basics
Review of the basics of Python (FizzBuzz)
Basics of Quantum Information Theory: Entropy (2)
Basics of Python x GIS (Part 2)
Basics of touching MongoDB with MongoEngine
perceptron
Read "Basics of Quantum Annealing" Day 6
About the basics list of Python basics
Learn the basics of Python ① Beginners
Basics of binarized image processing with Python
Basics of Quantum Information Theory: Data Compression (1)
Learn the basics of Theano once again
[Learning memo] Basics of class by python
[Python3] Understand the basics of Beautiful Soup
Visualize the boundary values of the multi-layer perceptron
I didn't know the basics of Python
Basics of Quantum Information Theory: Horebaud Limits
Basics: Full Search of Tree Structure (DFS/BFS)
The basics of running NoxPlayer in Python
Basics of Tableau Basics (Visualization Using Geographic Information)
[Basics of python basics] Why do __name__ == "__main__"
Jupyter Notebook Basics of how to use
Basics of PyTorch (1) -How to use Tensor-
Basics of Quantum Information Theory: Trace Distance
[Linux] Learn the basics of shell commands
Gacha written in python-Practice 2 ・ Basics of step-up gacha-
[Python] Chapter 02-04 Basics of Python Program (About Comments)
Basics of Quantum Information Theory: Quantum State Tomography
[Python] Chapter 02-03 Basics of Python programs (input / output)
Basics of Quantum Information Theory: Data Compression (2)
[Introduction to Data Scientists] Basics of Python ♬
[Python3] Understand the basics of file operations
Learn while implementing with Scipy Logistic regression and the basics of multi-layer perceptron