Meet YOLO26: next-gen vision AI.
Ultralytics
Back to Ultralytics Glossary

Activation Function

Explore how activation functions like ReLU, Sigmoid, and SiLU enable deep learning. Learn how Ultralytics YOLO26 uses these to master complex visual patterns.

An activation function is a fundamental component of a neural network (NN) that determines the output of a neuron given a set of inputs. Often described as the "gatekeeper," it decides whether a neuron should be active—meaning it contributes to the network's prediction—or inactive. Without these mathematical operations, a neural network would behave like a simple linear regression model, unable to grasp complex patterns regardless of its depth. By introducing non-linearity, activation functions enable deep learning (DL) models to learn intricate structures, such as the curves in handwritten digits or subtle anomalies in medical image analysis.

Link to this sectionCore Functionality and Common Types#

The primary role of an activation function is to map input signals to a desired output range and introduce complexity into the feature maps generated by the network. Developers select specific functions based on the layer's position and the objectives of the model training process.

  • ReLU (Rectified Linear Unit): Currently the most widely used function for hidden layers. It outputs the input directly if it is positive and zero otherwise. This simplicity accelerates computation and helps mitigate the vanishing gradient problem, a frequent challenge when training deep architectures.
  • Sigmoid: This function "squashes" input values into a range between 0 and 1. It is frequently employed in the final layer for binary classification tasks, such as determining if an email is spam, as the output can be interpreted as a probability score.
  • Softmax: Essential for multi-class problems, Softmax converts a vector of numbers into a probability distribution where all values sum to one. This is standard in image classification challenges like those found in the ImageNet dataset.
  • SiLU (Sigmoid Linear Unit): A smooth, non-monotonic function often used in state-of-the-art architectures like YOLO26. SiLU allows for better gradient flow than ReLU in very deep models, contributing to higher accuracy.

Link to this sectionReal-World Applications in AI#

The choice of activation function directly impacts the performance and inference latency of AI systems deployed in daily operations.

  1. Retail Object Detection: In automated checkout systems, object detection models identify products on a conveyor belt. Hidden layers use efficient functions like ReLU or SiLU to process visual features rapidly. The output layer determines the class (e.g., "apple," "cereal") and the bounding box coordinates, enabling the system to tally the bill automatically. This is critical for AI in retail to ensure speed and customer satisfaction.

  2. Sentiment Analysis: In natural language processing (NLP), models analyze customer reviews to gauge satisfaction. A network might process text data and use a Sigmoid function in the final layer to output a sentiment score between 0 (negative) and 1 (positive), helping businesses understand customer feedback at scale using machine learning (ML).

Link to this sectionImplementation Example#

You can visualize how different activation functions transform data using the PyTorch library. The following code snippet demonstrates the difference between ReLU (which zeroes out negatives) and Sigmoid (which squashes values).

import torch
import torch.nn as nn

# Input data: negative, zero, and positive values
data = torch.tensor([-2.0, 0.0, 2.0])

# Apply ReLU: Negatives become 0, positives stay unchanged
relu_output = nn.ReLU()(data)
print(f"ReLU:    {relu_output}")
# Output: tensor([0., 0., 2.])

# Apply Sigmoid: Squashes values between 0 and 1
sigmoid_output = nn.Sigmoid()(data)
print(f"Sigmoid: {sigmoid_output}")
# Output: tensor([0.1192, 0.5000, 0.8808])

It is important to differentiate activation functions from other mathematical components in the learning pipeline.

  • Activation Function vs. Loss Function: An activation function operates during the forward pass to shape the neuron's output. A loss function, such as Mean Squared Error, calculates the error between the prediction and the actual target at the end of the forward pass.
  • Activation Function vs. Optimization Algorithm: While the activation function defines the output structure, the optimizer (like Adam or Stochastic Gradient Descent) decides how to update the model weights to minimize the error calculated by the loss function.
  • Activation Function vs. Transfer Learning: Activation functions are fixed mathematical operations within the network's layers. Transfer learning is a technique where a pre-trained model is adapted for a new task, often preserving the activation functions of the original architecture while fine-tuning the weights on a custom dataset via the Ultralytics Platform.

For a deeper dive into how these functions fit into larger systems, explore the PyTorch documentation on non-linear activations or read about how computer vision tasks rely on them for feature extraction.

Explore solutions

Real-time AI that works with your team

AI in Robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Real-time AI that works with your team

AI in Logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Real-time AI that works with your team

AI in Retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Real-time AI that works with your team

AI in Healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Real-time AI that works with your team

AI in Manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Real-time AI that works with your operation

AI in Automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Real-time AI tailored to your operation

AI in Agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more
Real-time AI that works with your team

AI in Robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Real-time AI that works with your team

AI in Logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Real-time AI that works with your team

AI in Retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Real-time AI that works with your team

AI in Healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Real-time AI that works with your team

AI in Manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Real-time AI that works with your operation

AI in Automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Real-time AI tailored to your operation

AI in Agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more
Real-time AI that works with your team

AI in Robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Real-time AI that works with your team

AI in Logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Real-time AI that works with your team

AI in Retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Real-time AI that works with your team

AI in Healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Real-time AI that works with your team

AI in Manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Real-time AI that works with your operation

AI in Automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Real-time AI tailored to your operation

AI in Agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning