Layer

A layer is one stage of a neural network: a set of neurons that takes the previous stage's output, transforms it, and passes the result on to the next stage.

Neural networks are built as stacks of layers. Google's machine learning glossary defines a layer as a set of neurons and names three kinds by position. The input layer holds the data being fed in. The output layer produces the prediction. Everything in between is a hidden layer. A network with more than one hidden layer is a deep neural network, which is where the deep in deep learning comes from.

Each layer does a fixed kind of calculation, usually weighted sums followed by an activation function, and has its own learned weights. Data passes through the stack in order, each layer reshaping the representation it receives. Training adjusts the weights in every layer at once so that the final output gets closer to the right answer.

Layers come in types suited to different data. In a dense, or fully connected, layer every neuron connects to every neuron in the layer before. Convolutional layers scan images for features such as edges, textures and patterns, and pooling layers shrink the data. Recurrent layers carry a memory along a sequence. Normalisation layers keep values in a steady range, which helps training. Large language models are mostly made of repeated blocks of self-attention, feed-forward and normalisation layers.

AlexNet, the image recogniser that won the ImageNet competition in 2012, shows the scale of an earlier era: eight layers, five convolutional and three fully connected, with about 60 million parameters. Today's large models stack many more layers and have far more parameters.

Layers also matter for running models. A model too big for one chip is often split so that different layers sit on different GPUs, with data passing from one to the next. More layers can add capacity, but every extra layer adds computation to every answer.

Common questions

What is a layer in a neural network?

It is a group of neurons that processes data at one stage of the network. It takes the output of the previous layer, applies its own learned weights and an activation function, and passes the result to the next layer.

What are input, hidden and output layers?

The input layer holds the data going in, the output layer gives the final prediction, and hidden layers are everything in between. The hidden layers are where the network builds up its internal representations.

What does deep mean in deep learning?

It refers to depth in layers. A network with more than one hidden layer is called a deep neural network, and modern models stack many layers.

Do more layers make a model better?

Not automatically. More layers give a network more capacity to learn complex patterns, but they also make it slower to run and harder to train. Performance depends on the data, the training method and the architecture as a whole.

Finding more

Search for "neural network layers explained", "hidden layer" or a specific type such as "convolutional layer" or "attention layer". Reliable sources include machine learning courses from universities and providers such as Google, the documentation of frameworks such as PyTorch and TensorFlow, and the original architecture papers on arXiv. Layer counts quoted for commercial models are often estimates unless the developer has published them.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.