探索 SiLU (Swish) 激活函数如何提升深度学习在目标检测和自然语言处理等人工智能任务中的性能。
The Sigmoid Linear Unit, commonly referred to as SiLU, is a highly effective activation function used in modern deep learning architectures to introduce non-linearity into neural networks. By determining how neurons process and pass information through the layers of a model, SiLU enables systems to learn complex patterns in data, functioning as a smoother and more sophisticated alternative to traditional step functions. Often associated with the term "Swish" from initial research on automated activation search, SiLU has become a standard in high-performance computer vision models, including the state-of-the-art YOLO26 architecture.
At its core, the SiLU function operates by multiplying an input value by its own Sigmoid transformation. Unlike simple threshold functions that abruptly switch a neuron between "on" and "off," SiLU provides a smooth curve that allows for more nuanced signal processing. This mathematical structure creates distinct characteristics that benefit the model training process:
SiLU 是许多尖端人工智能解决方案不可或缺的一部分,在这些解决方案中,精度和效率至关重要。
要充分理解SiLU,有必要将其与Ultralytics 中其他激活函数区分开来。
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 SiLU (which allows smooth negative flow).
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_out = nn.ReLU()(data)
print(f"ReLU: {relu_out}")
# Output: tensor([0., 0., 2.])
# Apply SiLU: Smooth curve, small negative value retained
silu_out = nn.SiLU()(data)
print(f"SiLU: {silu_out}")
# Output: tensor([-0.2384, 0.0000, 1.7616])
By retaining information in negative values and providing a smooth gradient, SiLU plays a pivotal role in the success of modern neural networks. Its adoption in architectures like YOLO26 underscores its importance in achieving state-of-the-art performance across diverse computer vision tasks.