> ## Documentation Index
> Fetch the complete documentation index at: https://aegean.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Self-Supervised Learning

> Self-supervised representation learning for anomaly detection

## Self-supervised Learned (SSL) Representations

In what we will be calling from now on *Self-Supervised Learning* (SSL), we implicitly provide a supervisory signal to the representation learning process to improve performance by pulling the similar images closer together and pushing the dissimilar ones further apart.

The modeling approach follows this pipeline:

```
Pretrained Featurizer → SSL → Anomaly Detection
       ↓                 ↓
  Initial Features   Final Features
```

## Introduction to Contrastive Learning

The idea around contrastive learning is to pull together an anchor and a "positive" sample in embedding space, and push apart the anchor from many "negative" samples. Since no labels are available, a positive pair often consists of data augmentations of the sample, and negative pairs are formed by the anchor and randomly chosen samples from the mini-batch.

<img src="https://mintcdn.com/aegeanaiinc/-u553YOuO9vAksef/products/applications/anomaly-detection/manufacturing/unsupervised-learning-models/self-supervised/images/resnet-contrastive-learning.png?fit=max&auto=format&n=-u553YOuO9vAksef&q=85&s=b5de3070e471558acac9dc63a650f6bd" alt="Contrastive Learning with ResNet" width="1001" height="442" data-path="products/applications/anomaly-detection/manufacturing/unsupervised-learning-models/self-supervised/images/resnet-contrastive-learning.png" />

## Supervised Contrastive Learning

Supervised contrastive learning extends the contrastive learning paradigm by incorporating label information when available. This allows the model to leverage both the self-supervised contrastive signal and the supervised classification signal.

<img src="https://mintcdn.com/aegeanaiinc/-u553YOuO9vAksef/products/applications/anomaly-detection/manufacturing/unsupervised-learning-models/self-supervised/images/supervised-cross-entropy.png?fit=max&auto=format&n=-u553YOuO9vAksef&q=85&s=ceee8071abfe1384440a43d2a3ad4f31" alt="Supervised Cross-Entropy" width="2248" height="1062" data-path="products/applications/anomaly-detection/manufacturing/unsupervised-learning-models/self-supervised/images/supervised-cross-entropy.png" />

***

<Callout icon="pen-to-square" iconType="regular">
  [Edit this page on GitHub](https://github.com/aegean-ai/eaia/edit/main/src/products/applications/anomaly-detection/manufacturing/unsupervised-learning-models/self-supervised/index.mdx) or [file an issue](https://github.com/aegean-ai/eaia/issues/new/choose).
</Callout>
