当前位置:网站首页>Self learning neural network sequence -- 2 perceptron
Self learning neural network sequence -- 2 perceptron
2022-06-26 09:09:00 【ML_ python_ get√】
perceptron
2.1 What is a perceptron
- Accept multiple input signals , Output a signal
- Neuron : Weighting the input signal , If the weighted number meets a certain condition, enter 1, Otherwise output 0
- The weight represents the importance of the signal
2.2 And or not
- And gate : Only two inputs are 1 When the output 1, Other situation output 0
- NAND gate : Invert the and gate output , Only two inputs are 1 When the output 0, Otherwise output 1
- Or gate : As long as one input is 1, Then output 1, Only all inputs are 0, Just output 0
- As long as the parameters of the sensor are adjusted, the switch between different doors can be realized
- Parameter adjustment is left to the computer , Let the computer decide what kind of door
- Exclusive OR gate : Only one input is 1 when , Will enter 1, The two inputs are 1 when , Output 0
# python Implement and gate
def AND(x1,x2):
''' Implementation of and gate '''
w1,w2,theta = 0.5,0.5,0.7
tmp = x1*w1+x2*w2
if tmp<=theta:
return 0
elif tmp>theta:
return 1
# Test functions
AND(1,1)
AND(0,0)
AND(1,0)
AND(0,1)
# Use offset and numpy Realization
def AND(x1,x2):
import numpy as np
x = np.array([x1,x2])
w = np.array([0.5,0.5])
b = -0.7 # threshold , Adjust how easily neurons are activated
tmp = np.sum(w*x) +b
if tmp<=0:
return 0
elif tmp>0:
return 1
# test
AND(1,1)
AND(1,0)
AND(0,1)
AND(0,0)
# NAND gate
# The output is just the opposite , The weights and offsets are opposite to each other
def NAND(x1,x2):
''' NAND gate '''
import numpy as np
x = np.array([x1,x2])
w = np.array([-0.5,-0.5])
b = 0.7
tmp = np.sum(w*x)+b
if tmp <=0:
return 0
elif tmp>0:
return 1
# test
NAND(1,1)
NAND(1,0)
NAND(0,1)
NAND(0,0)
# Or gate : The absolute value of the offset is less than 0.5 that will do
def OR(x1,x2):
import numpy as np
x = np.array([x1,x2])
w = np.array([0.5,0.5]) # As long as not both inputs go 0, It outputs 1
b = -0.2
tmp = np.sum(w*x)+b
if tmp<=0:
return 0
else:
return 1
OR(1,1)
OR(0,1)
OR(1,0)
OR(1,1)
# Exclusive OR gate : Cannot be separated by a straight line
# Introduce nonlinearity : Overlay layer perceptron
# Through the NAND gate, we get S1 Or door access S2 You can see the result of the XOR gate that can be reached through the and gate
# Multilayer perceptron , There are multiple linear classifiers , The nonlinear fitting can be realized through and gate
def XOR(x1,x2):
s1 = NAND(x1,x2)
s2 = OR(x1,x2)
y = AND(s1,s2)
return y
# test
XOR(1,1)
XOR(0,0)
XOR(1,0)
XOR(0,1)
边栏推荐
- Autoregressive model of Lantern Festival
- 滑块验证 - 亲测 (京东)
- docker安装redis
- 百度小程序富文本解析工具bdParse
- Fix the problem that the rich text component of the applet does not support the properties of video cover, autoplay, controls, etc
- XSS 跨站脚本攻击
- Applet realizes picture preloading (picture delayed loading)
- Reverse crawling verification code identification login (OCR character recognition)
- 如何利用最少的钱,快速打开淘宝流量入口?
- Pytorch neural network
猜你喜欢

【C】青蛙跳台阶和汉诺塔问题(递归)

Dedecms applet plug-in is officially launched, and one click installation does not require any PHP or SQL Foundation

phpcms小程序插件4.0版正式上线

行为树的基本概念及进阶

设置QCheckbox 样式的注意事项

百度小程序富文本解析工具bdParse

Section IV HQL execution process

力扣399【除法求值】【并查集】

Phpcms applet plug-in tutorial website officially launched

phpcms v9去掉phpsso模块
随机推荐
微信小程序如何转换成百度小程序
Autoregressive model of Lantern Festival
什么是乐观锁,什么是悲观锁
远程工作的一些命令
Pytorch neural network
Implementation code of interceptor and filter
20220623 getting started with Adobe Illustrator
1.20 study univariate linear regression
Unity webgl publishing cannot run problem
phpcms小程序插件教程网站正式上线
框架跳转导致定位失败的解决方法
1.23 neural network
编程训练7-日期转换问题
【C】青蛙跳台阶和汉诺塔问题(递归)
Practice is the fastest way to become a network engineer
Unity WebGL发布无法运行问题
Computer mall based on SSM
Phpcms applet plug-in version 4.0 was officially launched
1.26 pytorch learning
运行时端的执行流程