UX / UI Design / How Neural Networks Work in 2023: Explained With Bananas

How Neural Networks Work in 2023: Explained With Bananas

Not a day goes by without a proclamation like "Copywriting is done" and "Designers will be replaced by a new version of ChatGPT" from some Telegram channel or news site. And even though neural networks have a long way to go before they completely replace humans, they are developing very quickly indeed.

In the spring, neural networks started getting pretty good at writing basic posts. Now they can replace an actor in a video with an alien or a robot, while managing to do it faster than any human and without huge budgets. All we can do is sit and wonder what awaits us in the fall.

Today, we will talk about how neural networks are organized using the simplest example: image generation.

Principles Behind a Neural Network

Modern neural networks can be compared to virtual models of the brain, which are comprised of many interconnected nodes. Each node is a small computing unit that performs a certain mathematical operation. The results of the operations leading to other nodes are called connections.

Let's imagine that we have created a neural network that's supposed to identify bananas in an image. First, it will ask itself this: "What color is the object?". This question becomes a node of the network. The answers to this question — colors of the objects — function as connections between nodes. If the color of a potential banana is yellow, green, or brown, the object is more likely to be marked as "banana".

Connections between nodes of a neural network can vary in weight, which indicates the strength of one node's influence on another. This weight is determined during the neural network training process. When training a neural network on banana images, the "heavier" connections for the "color" node will be the ones leading to the "yellow," "green", and "brown" nodes.

If you only use images of ripe bananas for training, "yellow" will have more weight. This means that images containing the color yellow will be more likely to be identified as depicting bananas (after additional checks, of course), and the absence of anything yellow in the image will mean that there is probably no banana there.

image1.png “Yellow,” “green”, and “brown” connections have more weight in identifying a banana

A neural network is like a tree of possibilities with mathematical operation nodes for branches. However, if we imagine a neural network as a tree, its branches will have to be of different thicknesses. Some will grow into other branches because of their weight that is adjusted during training and determines the degree of influence of one node on another.

Once the network is trained, and the weight of its connections has been established, it can be used for a specific task. For example, to classify an image by determining whether there is a banana in it.

Neural Network Training Procedure

To understand how everything works within the complexity of nodes and connections in neural networks, let's consider a simple example with apples and bananas.

Step 1. Data input. We feed our hypothetical neural network a set of images of apples and bananas. The neural network's task is to find bananas, so at this stage we will "tell" it which images have bananas in them. The neural network uses this data to make a prediction.

Step 2. Propagation. Knowing that this is a banana-marked image it is dealing with, the program collects parameters to explain why the user labeled it so. The neural network starts running the picture through its nodes. At first, the connections have no weight, so the first images go through the learning algorithm at random.

image3.png The neural network compares two banana-marked images and looks for similarities between them. This is its way of trying to figure out why the user labeled the picture as “banana”

It is as if the neural network node is asking: "Is this object yellow?". And the first images go every which way. Some are marked as yellow and some are not, even though there might be something yellow in the image.

Step 3. Error counting. At this stage, the neural network compares predicted and actual results based on how each image is labeled. This is how it counts errors.

Which means that all those banana images that were marked as "not yellow" at the color detection stage are marked as erroneous, and the "bananas — yellow" connection is given more weight.

Step 4. Backpropagation. Error values are used to adjust weights of artificial neurons in the network. First, the error between the predicted and the actual output is calculated. Then this error is propagated backwards through the network.

Moreover, an error gradient needs to be calculated for each artificial neuron. The error gradient indicates how much a change in weight affects the correctness of banana detection.

When calculating gradients, it is important to determine the direction in which neuron weights need to be changed in order to reduce error probability as quickly as possible.

Step 5. Weight distribution. Neuron weights are distributed in a way to minimize the loss value in error counting. For example, the yellow-colored images are more likely to be those of "bananas".

Step 6. Training. The neural network loops over all of the previous steps with different data, counting errors and distributing weights over and over again. This continues until it reaches the desired level of accuracy.

Normally, it is the user who trains the neural network and determines its readiness. But now neural networks can train each other, with one of them checking the other one's results. Just like a graduate student who got a degree and became a teacher at the same university.

Step 7. Prediction. Once the neural network is trained, it can be used to make predictions on new data. The prediction process is similar to forward propagation, where input data is converted into a predicted output. But instead of being random, now it is based on neuron weights.

Neural networks have already become a powerful tool in many areas, including marketing (hello, Coca-Cola), design, programming and many others. Even this article is 70% written by a neural network, although we tried to make it more understandable. We hope that we've helped you make some sense of the principles behind neural networks.

Please subscribe to our LinkedIn so you never miss out on our other posts.