当前位置:网站首页>06. Neural network like
06. Neural network like
2022-07-25 14:39:00 【A rookie who can't burn to death is called Phoenix】
One 、 Single layer perceptron model
( One ) Model diagram

( Two ) Purpose : Build universal functions


The following activation functions are used : Hidden layer to output layer , When output
1、 What to use activation function
1、 Easy derivation , Carry out back propagation calculation ;
2、 Output according to human needs Y Map to a space ;
3、 Activation functions introduce nonlinear factors into neurons , So that the neural network can arbitrarily approximate any nonlinear function , So the neural network can be applied to many nonlinear models .
2、 Commonly used activation functions and python Realization
1、 Step activation function :: With 0 Activate for valve , Otherwise closed
The function diagram :
Code practice :
import numpy as np
def threshold_function (x):
y=x>0# If x It's an array , The result after execution is greater than 0 Elements correspond to y Array elements are true And vice versa false. Such as x=[-1,1,2], be y=[false,true,ture].
return y.astype(int)#astype Transformation of data types , hold y Convert to the type in brackets , hold y=[false,true,ture] Convert to [0,1,1]
x=np.array([-1,1,2])
threshold_function(x)
2、sigmoid Activation function : Output the value to (0~1), Used to sort probability size, etc
The function diagram :
Advantages and disadvantages :
Code practice :
def sigmoid (x):
return 1/(1+np.exp(-x))#exp, yes np Functions inside , Can't be without ‘np.’ Use it directly 'exp(-x)'
x=np.array([-1,1,2])
sigmoid(x)# After the change ‘array([0.26894142, 0.73105858, 0.88079708])’
3、Tanh Activation function :: Map the output value to (-1~1)
The function diagram :

Advantages and disadvantages :
Code practice :
import numpy as np
def tanh (x):
return (1- np.exp(-2*x))/(1+np.exp(-2*x))#‘2*x’ Can't make it ‘2x’
x=np.array([-1,1,2])
tanh(x)
# Output :array([-0.76159416, 0.76159416, 0.96402758])
4、ReLu Activation function : Do not reach the valve ‘0’ Time is ‘0’, After activation , Linear increase
The function diagram :
Advantages and disadvantages :
Code practice :
import numpy as np
def relu(x):
return np.maximum(0,x)#0 It used to be 0, Greater than 0 Linear increase
x=np.array([-1,1,2])
relu(x)
# Value after change :array([0, 1, 2])
( 3、 ... and ) Neural network propagation process : above all
1、 Model diagram

2、 Add offset

3、 Communication process :
First step : Positive communication : Get the difference between the predicted value and the real value
The second step : Back propagation : By gradient descent , Update parameters : The weight weight And deviation bias
The third step : Forward propagation again Use the updated parameters , Continue Prequel , Get the difference between the predicted value and the real value again
Step four : Back propagation again By gradient descent , Update parameters : The weight weight And deviation bias
**········:** By iterating back and forth repeatedly, the predicted value and the real value are minimized , Also get the final parameter value .
Use the output softmax Functions are standardized , Add to one .
4、 The basic knowledge involved in the dissemination process
1、 error ( Loss ) function : Measure the difference between the predicted value and the real value
The first one is : Mean square deviation function :
The second kind : Cross entropy loss function :
2、 Output layer activation function
softmax: Standardize the output .
Use location : One to one mapping of predicted value to output value .
Mapping example diagram :
3、 Gradient descent method : Make an error ( Loss ) Function minimization algorithm
explain : Given a set of function parameters , The gradient decreases from a set of initial parameter values ( Set casually at the beginning ) Start , The iteration moves to a set of parameter values that minimize the loss function . This iterative minimization is achieved using calculus , Take a gradient change in the negative direction of the gradient . As the model iterates , The loss function gradually converges to the minimum .
Calculate the partial differential
** explain :** Because it is a set of parameters, which are composed of weight and deviation , So it's partial differential .
** Purpose :** Find the parameter combination with the fastest reduction of function value
Add :
The slope of a point ( Partial differential at some point ) Positive of 、 A negative value indicates which direction to adjust , Big 、 A small value indicates the adjustment range ;
The slope of a point ( Partial differential at some point ) The more novel is clear, the closer it is to the ideal point , The bigger the adjustment, the bigger .
Central difference : An alternative way of calculating partial differential 
Purpose : solve H The influence of value on the result , It can make the partial differential closer to the demand ( It's just that the calculation is more accurate ).
A comparison of the two :
def func (x):
return x**2
def dfunc (f,x):
h=1e-4# Define an extremely small moment
return (f(x+h)-f(x-h))/(2*h)
dfunc(func,3)
# Partial differential method :6.000100000012054
# The difference method :6.000000000012662
** 4、 The problem of learning rate **
explain : Multiply by a learning rate , Make it reach the minimum value slowly , It must be known from experiments , It is usually set to :0.01 or 0.1 etc.
Be careful : Choosing the right learning rate is one of the key factors
annotation : It's error ( Loss ) Partial differential of function to parameter
( Four ) shortcoming : Cannot solve the XOR gate problem
resolvent : By combining multi-layer perceptron , To carry out XOR Problem input / output control .
5、 ... and 、 Add
1、W It means :W The row represents the number of hidden layer nodes ( Number of outputs ), The number of columns represents X dimension ( Enter the number )
2、 The most basic and commonly used model
Every neuron has two basic operations :
1、 Aggregate input ;2、 Activate aggregation .
Get the predicted values of all training samples :
Scan the training set horizontally from left to right
Sweep each node vertically from top to bottom

边栏推荐
猜你喜欢

The security market has entered a trillion era, and the security B2B online mall platform has been accurately connected to deepen the enterprise development path

Save the image with gaussdb (for redis), and the recommended business can easily reduce the cost by 60%

Gameframework making games (I)

PS making and loading GIF pictures tutorial

IP地址分类,判断一个网段是子网超网

微信公众号正式环境上线部署,第三方公众平台接入

SQL优化的一些建议,希望可以帮到和我一样被SQL折磨的你
Famous handwritten note taking software recruit CTO · coordinate Shenzhen

The supply chain collaborative management system, a new "engine" of digitalization in machinery manufacturing industry, helps enterprises' refined management to a new level

MySQL table operation
随机推荐
easygui使用的语法总结
Two Sum
awk从入门到入土(20)awk解析命令行参数
The security market has entered a trillion era, and the security B2B online mall platform has been accurately connected to deepen the enterprise development path
关于ROS2安装connext RMW的进度条卡在13%问题的解决办法
Spark parameter adjustment and tuning
[nuxt 3] (XI) transmission & module
kibana操作es
CTS test introduction (how to introduce interface test in interview)
GameFramework制作游戏(一)
Idea settings ignore file configuration when submitting SVN
Under the epidemic, the biomedical industry may usher in breakthrough development
How to design a high concurrency system?
DVWA practice - brute force cracking
06、类神经网络
English语法_不定代词 - other / another
D2. picking carrots (hard version) (one question per day)
【cartographer_ros】八: 官方Demo参数配置和效果
VS2017大型工厂ERP管理系统源码 工厂通用ERP源码
spark参数调整调优