Gnox AI / Blog

,

Neural Networks in AI: How They Work, With an Example

Blue and pink three-dimensional structures illustrating how neural networks process input and output data

A neural network is a machine learning model that transforms inputs into a prediction through connected layers of calculations. During training, it learns numerical weights that determine which signals affect the output and by how much. Neural networks can recognize objects in images, transcribe speech, and generate text.

How layers turn inputs into a prediction

The input is a numerical representation of the data, such as pixel values or a vector representing a text token. Hidden layers transform those numbers into intermediate representations. The output layer produces a result suited to the task, such as a score for each category or a predicted delivery time.

In a basic dense layer, a node multiplies each incoming value by a weight, adds the products and a bias, then applies an activation function. The bias shifts the result by a learned amount. An activation such as ReLU keeps positive values and sets negative ones to zero.

A worked example of a neural network node

Imagine a package-delay model with two normalized inputs: an unusual wait at a depot, valued at 2, and a route signal, valued at 1. In this fictional model, one hidden node computes (0.6 × 2) + (−0.4 × 1) + 0.1 = 0.9. ReLU leaves the positive result at 0.9.

If the depot input drops to 0 and everything else stays fixed, the raw result becomes −0.3 and ReLU outputs zero. The next layer receives that changed signal. The node’s 0.9 is an intermediate value. A delay probability would come from the model’s output and how it was trained and evaluated.

How a neural network learns

During supervised training, the network predicts an output and a loss function measures the difference from the expected result. Backpropagation calculates how changes to the weights affect that loss, and an optimizer uses those gradients to update the weights. The machine learning epochs guide explains how batches, steps, and training passes fit together.

During inference, the prepared model applies the weights it has learned to new data. A low training loss does not establish that it works well on new inputs, so teams test on data kept separate from training. See our guide to deep learning inference for the prediction stage.

Common types of neural networks

Feedforward networks pass information from input to output without a recurrent loop. They can make numerical predictions or assign inputs to categories. Convolutional neural networks apply learned filters across locations, which lets the same filter look for a useful pattern across an image.

A recurrent neural network passes a state from one step of a sequence to the next. A transformer uses attention to combine information across parts of the input. The transformer model guide explains why attention is useful for language tasks.

Larger networks require more memory or compute. Hardware such as GPUs can speed up the repeated matrix operations, but hardware speed does not improve the model’s accuracy on its own.

For how neural networks fit into the wider field, see deep learning vs. machine learning.

How does a neural network differ from an LLM?

A neural network is a broad class of models. A large language model is a neural network trained at scale to process language. Both learn weights and use layers to transform numerical inputs. What differs is the task and the training objective. An image classifier might take pixels and return a score for each object category. A language model takes tokens and can score which token should come next, using that prediction repeatedly to generate text.

Many modern language models use transformers, while an image classifier might use a convolutional network or a vision transformer. The architecture helps describe how the model processes information. The training objective helps explain what the model can produce.

Frequently asked questions

Is an LLM a neural network?

Modern large language models are neural networks trained to process and generate sequences of tokens. Many use a transformer. Other neural networks are built for tasks such as image recognition or predicting a number.

What is a hidden layer?

It is a set of computations between the input and output. Its values are intermediate representations the next part of the model can use.

Why do neural networks need activation functions?

Nonlinear activations let a network learn relationships that a chain of linear transformations cannot express. A sequence of weighted sums with biases alone still collapses into a single linear transformation with an offset.

Can a neural network be used for reinforcement learning?

Yes. It can represent a policy that selects actions or estimate the value of an action or state. The learning signal comes from interaction and rewards.