What is Neural Network?

Overview

In short, a neural network can be viewed as a function: it takes input data and generates output results.

Defining Functions

We illustrate the function form of a neural network through MNIST Handwritten Digit Recognition:

  • Task Type: Image Classification
  • Input: Each 28 x 28 image, consisting of 784 pixels, each represented by a real number
  • Output: Digits 0-9
  • Task Description: Identify the unique digit 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 a neural network. The input is a low-resolution (28 x 28) black-and-white image, with 784 input variables. If the input were a million-pixel color image, the corresponding input variables would reach over 3 million.


Hence, neural networks solve complex problems by constructing complex functions. Implementing algorithms means constructing these functions.


How to construct such complex functions? We can start with simple functions, such as digital circuits.

Digital Circuits

Digital circuits are the cornerstone of modern computing, but at their core, they consist of simple AND, OR, and NOT logic gates.


What are logic gates? Essentially, 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

Combining Logic Gates

By combining simple logic gates, one can construct more complex functions.


for@example, to create new binary functions:

  • 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?