Explore Capsule Networks (CapsNets) and how they preserve spatial hierarchies to solve the "Picasso problem" in AI. Learn about dynamic routing and vector neurons.
Capsule Networks, often abbreviated as CapsNets, represent an advanced architecture in the field of deep learning designed to overcome specific limitations found in traditional neural networks. Introduced by Geoffrey Hinton and his team, CapsNets attempt to mimic the biological neural organization of the human brain more closely than standard models. Unlike a typical convolutional neural network (CNN), which excels at detecting features but often loses spatial relationships due to downsampling, a Capsule Network organizes neurons into groups called "capsules." These capsules encode not just the probability of an object's presence, but also its specific properties, such as orientation, size, and texture, effectively preserving the hierarchical spatial relationships within visual data.
To understand the innovation of CapsNets, it is helpful to look at how standard computer vision models operate. A conventional CNN uses layers of feature extraction followed by pooling layers—specifically max pooling—to reduce computational load and achieve translational invariance. This means a CNN can identify a "cat" regardless of where it sits in the image.
However, this process often discards precise location data, leading to the "Picasso problem": a CNN might classify a face correctly even if the mouth is on the forehead, simply because all the necessary features are present. CapsNets address this by removing pooling layers and replacing them with a process that respects the spatial hierarchies of objects.
The core building block of this architecture is the capsule, a nested set of neurons that outputs a vector rather than a scalar value. In vector mathematics, a vector has both magnitude and direction. In a CapsNet:
Capsules in lower layers (detecting simple shapes like edges) predict the output of capsules in higher layers (detecting complex objects like eyes or tires). This communication is managed by an algorithm called "dynamic routing" or "routing by agreement." If a lower-level capsule's prediction aligns with the higher-level capsule's state, the connection between them is strengthened. This allows the network to recognize objects from different 3D viewpoints without requiring the massive data augmentation usually needed to teach CNNs about rotation and scale.
Хотя обе архитектуры имеют основополагающее значение для компьютерного зрения (CV), они различаются по способу обработки и представления визуальных данных:
Хотя CapsNets часто требуют больших вычислительных затрат по сравнению с оптимизированными моделями, такими как YOLO26, они предлагают явные преимущества в специализированных областях:
Капсульные сети в первую очередь представляют собой архитектуру классификации. Хотя они обеспечивают теоретическую надежность, в современных промышленных приложениях часто предпочитают высокоскоростные CNN или трансформеры для обеспечения производительности в реальном времени. Тем не менее, полезно понимать бенчмарки классификации, используемые для CapsNets, такие как MNIST.
Следующий пример демонстрирует, как обучить современную
Модель YOLO на наборе MNIST с использованием
ultralytics пакет. Это соответствует основной тестовой задаче, используемой для валидации капсульных сетей.
from ultralytics import YOLO
# Load a YOLO26 classification model (optimized for speed and accuracy)
model = YOLO("yolo26n-cls.pt")
# Train the model on the MNIST dataset
# This dataset helps evaluate how well a model learns handwritten digit features
results = model.train(data="mnist", epochs=5, imgsz=32)
# Run inference on a sample image
# The model predicts the digit class (0-9)
predict = model("https://docs.ultralytics.com/datasets/classify/mnist/")
Принципы, лежащие в основе капсульных сетей, продолжают влиять на исследования в области безопасности и интерпретируемости ИИ. Благодаря явному моделированию отношений между частями и целым, капсулы предлагают альтернативу «черному ящику» в виде «стеклянного ящика» для глубоких нейронных сетей, что делает принятие решений более объяснимым. Будущие разработки направлены на объединение пространственной устойчивости капсул со скоростью вывода архитектур, таких как YOLO11 или более новой YOLO26 для улучшения производительности в области обнаружения 3D-объектов и робототехники. Исследователи также изучают матричные капсулы с EM-маршрутизацией для дальнейшего сокращения вычислительных затрат алгоритма согласования.
For developers looking to manage datasets and train models efficiently, the Ultralytics Platform provides a unified environment to annotate data, train in the cloud, and deploy models that balance the speed of CNNs with the accuracy required for complex vision tasks.