How does a neural network simulate an arbitrary function
Overview
The reason why the neural network is powerful lies in its powerful simulation ability. In theory, it can simulate arbitrary functions with infinitely small errors.
In other words, we can use neural networks to construct arbitrary functions and obtain arbitrary algorithms.
We use some visual examples here to help you gain some intuitive understanding.
Simulation of unary function
Straight line
This is the simplest case, we can simulate it by using a neuron without activation function.
f(x)=wx+b
w1
b0
By adjusting the w,b parameters, any straight line can be simulated.
Step function
We use a neuron with Sigmoidactivation function to simulate it.
w30
b0
As the w parameter continues to increase, the neural network will gradually approach the function.
Rectangular pulse function
We divide it into several steps:
Use a single neuron to simulate the left half of the function.
f1(x)=sigmoid(w1x+b1)
w120
b120
Use a single neurons to simulate the right half of the function (upside down).
f2(x)=sigmoid(w2x+b2)
w220
b2-20
Use another neuron to synthesize the images of the first 2 steps
f3(x,y)=sigmoid(w31x+w32y+b3)
w3110
w32-10
b3-5
The result obtained is a good approximation of the objective function.
Other unary functions
Using the rectangular impulse function, we can easily approximate other arbitrary functions, just like the principle of integration.
n10
Experiment
Complete Broken Line mission and observe the function corresponding to each neuron.
This is the simplest case, we can simulate it by using a neuron without activation function.
f(x,y)=w1x+w2y+b
w10
w21
b0
By adjusting the parameters of w1,w2,b, any plane can be simulated.
Binary Step Function
We use a neuron with Sigmoidactivation function to simulate it.
f(x)=sigmoid(w1x+w2y+b)
w10
w230
b0
Binary rectangular impulse function
Similar to the case of unary functions, we implement it step by step:
Use a single neuron to simulate an edge of the function
f1(x,y)=sigmoid(w11x+w12y+b1)
w110
w1220
b120
Then we can get the following function:
wi10
wj-10
bi-5
Finally, the following functions can be synthesized
w5110
w52-10
w5310
w54-10
b5-15
The final neural network structure is shown in the figure below:
Other binary functions
Using the binary rectangular impulse function, we can easily approximate any other binary function, just like the principle of integration.
Experiment
Complete the Circle mission and observe the function corresponding to each neuron.
The principle is the same, imagine for yourself! 😥
Question
We already have digital circuits and software program algorithms, why do we need neural networks?
Software programs built on digital circuits can also simulate arbitrary functions, so why invent artificial neural networks?