What is Neural Network?

Overview

In short, Neural network is a function: input data, output result.

Function

Let's take MNIST handwritten digit image recognition as an example to define the corresponding function form:

  • Task Type: Image classification
  • Input: An image contains 28 x 28=784 pixels, and each pixel is represented by a real number
  • Output: 0-9
  • Task description: Identify the unique number from the image
  • Function Definition
y=f(x1,x2,...,x784)xiR,i=1,...,784y{0,1,...,9}\begin{aligned} y &= f(x_1, x_2, ..., x_{784}) \\ &x_i \in \mathbb R, i = 1, ..., 784 \\ &y \in \{0, 1, ..., 9\} \end{aligned}

This is an entry-level application of Neural Network. The input is a low-resolution (28 x 28) grayscale image, corresponding to a function with 784 input variables. If it is a megapixel color image, the corresponding input variables will reach 3 million.


It can be seen that the neural network is used to solve some complex problems, and the corresponding functions are also complex. The realization of the algorithm is to construct the corresponding function.


How to construct such a complicated function? We can start with simple functions. The simplest and most successful example is digital circuits.

Digital circuits

Digital circuits are the cornerstones of computers, and have built our huge digital world. But its core is composed of AND, OR, and NOT logic gates.


What is a logic gate? It's actually a function. And they are the simplest functions.

Logic gateexpressionfunction form
AND gatexyx \land yz=(x,y)z = \land(x, y)
OR gatexyx \lor yz=(x,y)z = \lor(x, y)
NOT gate¬x\lnot xy=¬(x)y = \lnot(x)
  • Variable type: All boolean variables, only 2 values: {T,F}\{T, F\}, much simpler than natural numbers (N\mathbb N) and real numbers (R\mathbb R).
  • Number of variables: unary or binary function, which is also the simplest form of function
  • Function representation: use truth table for description. Why not use images? Because it is a discrete function, there are some isolated points on the image, which is not very attractive.

NOT gate

xx¬x\lnot x
TTFF
FFTT

NOT gate image (use 0 for FF and 1 for TT)

AND gate, OR gate

xxyyxyx \land yxyx \lor y
TTTTTTTT
TTFFFFTT
FFTTFFTT
FFFFFFFF

AND gate image

OR gate image

Combination logic gate

Combine simple logic gates to get more powerful functions.


Construct a new binary function:

  • XOR: xy=(x¬y)(¬xy)x \oplus y = (x \land \lnot y) \lor (\lnot x \land y)
  • XNOR: xy=(xy)(¬x¬y)x \odot y = (x \land y) \lor (\lnot x \land \lnot y)

Construct a multivariate function:

  • 3-bit AND operation: f(x,y,z)=xyzf(x, y, z) = x \land y \land z
  • 8-bit adder: f(x1,...,x8,y1,...,y8)f(x_1, ..., x_8, y_1, ..., y_8)
    • It is a 16-element function containing 16 Boolean variables
  • 32-bit adder: f(x1,...,x32,y1,...,y32)f(x*1, ..., x*{32}, y*1, ..., y*{32})
    • It is a 64-element function containing 64 Boolean variables
    • It can also be regarded as a binary function of 32-bit integers: f(x,y)x,yInt32f(x, y) \quad x, y \in \text{Int32}

Summary

By combining simple logic gate functions, new logic functions can be constructed. Including operations such as addition, subtraction, multiplication, and division of 32-bit integers, and operations of 32-bit single-precision floating-point types, etc.

Programming language

Let's look at programming languages again. Take Python as an example, look at the elements in Python.

Operator

NameSymbolFunction
Logical operatorsand or notBinary and unary logic functions
Arithmetic Operators+, -, *, /, %, **, //Binary Functions
Comparison operators==, !=, >, <, >=, <=Binary functions
...

Taking the floating-point number addition operator (+) as an example, the function image is as follows:

f(x,y)=x+yf(x, y) = x + y

Functions

You can define your own functions in Python:

def f(x, y): return max(0, 2*x + 3*y - 3)

A new function is defined here. It uses "+, -, *, max" and other functions to construct the new function. The method of construction is also through the composition of functions.

Summary

Functions are everywhere in programming languages. By combining basic functions, new functions can be constructed and new algorithms can be obtained.

Neural Network

Neural network is also function. Like digital circuits and programming languages, it is also composed of simple functions. The basic units of digital circuits are logical functions such as AND, OR, and NOT. The basic units in programming languages are functions such as various operators, while the basic unit of neural networks is neurons.

Neuron

So what is a neuron? A biological neuron is a cell with input dendrites and output axons. And the neuron on the neural network is an artificial neuron, it is also a function, more precisely, it is a kind of function.


The number of inputs of neurons can be changed, which means that it represents a nn-element function f(x1,...,xn)f(x_1, ..., x_n), and nn can be different for different neurons.

Neural Network

Neurons combine with each other to form a neural network. As shown below:

A neural network is a function composed of neuron functions. A neuron function is a function composed of simple functions, such as AND, OR, and NOT.

The neural network contains three neurons(do not count input neurons):

  • f1(x1,...,xn)f_1(x_1, ..., x_n)
  • f2(x1,...,xn)f_2(x_1, ..., x_n)
  • f3(x1,x2)f_3(x_1, x_2)

The function represented by the neural network is:

f(x1,...,xn)=f3(f1(x1,...,xn),f2(x1,...,xn))f(x_1, ..., x_n) = f_3(f_1(x_1, ..., x_n), f_2(x_1, ..., x_n))

Summary

  1. The core of the digital circuits (hardware) is function, and its basic functions are the AND OR NOT logic gate functions;
  2. The core of programming languages (software) is function, and its basic functions are various operator functions and built-in functions (provided by hardware or compounded);
  3. The core of neural networks is also function, and its basic functions are neurons;
  4. New functions can be constructed through the composition of simple functions. Neural networks are functions constructed from neuron functions through function composition operations.

Question

What exactly is the function represented by a neuron?

Just knowing that it is a nn-element function is not enough. The basic units AND, OR, and NOT gates in digital circuits all list the truth table and draw the figure, but what about the neuron?