惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
云风的 BLOG
云风的 BLOG
小众软件
小众软件
雷峰网
雷峰网
博客园 - 【当耐特】
V
V2EX
WordPress大学
WordPress大学
IT之家
IT之家
Last Week in AI
Last Week in AI
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
The Cloudflare Blog
Jina AI
Jina AI
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
博客园 - 聂微东
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

Louis C Deng's Blog

RoPE: Properties, Patterns, and Long-Context Behavior CS336 Assignment 1: Large Language Model Training and Inference CS231n Lecture Note: Generative Models CS231n Lecture Note: Large Scale Distributed Training 自動微分 | DIY 實現自己的 PyTorch From RNNs to Transformers CS231n Lecture Note VII: Recurrent Neural Networks Uncovering Batch & Layer Normalization CS231n Lecture Note VI: CNN Architectures and Training CS231n Lecture Note V: Convolution Neural Networks Basics Demystifying Softmax Loss: A Step-by-Step Derivation for Linear Classifiers Backpropagation: A Vector Calculus Perspective CS231n Lecture Note IV: Neural Networks and Backpropagation CS231n Lecture Note III: Optimization CS231n Lecture Note II: Linear Classifiers CS231n Lecture Note I: Image Classification CSAPP Cache Lab II: Optimizing Matrix Transposition CSAPP Cache Lab I: Let's simulate a cache memory! CS188 Search Lecture Notes III CS188 Search Lecture Notes II How to Use TouchID for Sudo Commands on macOS CS188 Search Lecture Notes I RECAP2025: 留白 CSAPP Bomb Lab 解析 x64 暫存器速查表 CSAPP Data Lab 解析 矩陣的 Modified Gram Schmidt 方法 聊一聊位掩碼(Bit Mask) 整數溢位與未定義行為 快速排序 幾種劃分方法討論
CS231n Lecture Note: Self-Supervised Learning
Louis C Deng · 2026-05-02 · via Louis C Deng's Blog

With self-supervised learning, we can train neural networks without the need for manually labelled datasets.

Basics

We define a pretext task based on the data itself. It does not require manual annotation. The labels/outputs are automatically generated from the data. We train an encoder from them to get the learned representation.

These learned representations can then be reused for a downstream task, either by freezing the encoder and training a task-specific head, or by fine-tuning the encoder together with the downstream model.

Common pretext tasks include image completion, rotation prediction, jigsaw puzzle solving, colorization, contrastive learning, and masked image modeling.

Pretext tasks focus on “visual common sense”, forcing the model to learn good features.

Solving the pretext tasks allow the model to learn good features. And we can automatically generate labels for those tasks.

Evaluation

  1. Pretext Task Performance
  • Measure how well the model performs on the task it was trained on without labels.
  1. Representation Quality
  • Evaluate the quality of the learned representations:
    • Linear Evaluation Protocol: Train a linear classifier on the learned representations.
    • Clustering: Measure clustering performance.
    • t-SNE: Visualize the representations to assess their separability.
  1. Robustness and Generalization
  • Test how well the model generalizes to different datasets and is robust to variations.
  1. Computational Efficiency
  • Assess the efficiency of the method in terms of training time and resource requirements.
  1. Transfer Learning and Downstream Task Performance
  • Assess the utility of the learned representations by transferring them to a downstream supervised task.

Masked Auto Encoders (MAE)

We divide the input into non-overlapping patches. Uniformly sample a very large proportion (75%) of these patches and mask them.

Masking a high ratio makes the task challenging and meaningful.

The MAE encoder only operates on unmasked patches. We embed the patches by linear projection and add positional embeddings, and then use transformer blocks for the model.

For the MAE decoder, we merge the encoder outputs with the shared mask tokens in previously masked places, adding positional encodings to them. It uses transformer blocks, followed by a linear projection for finalizing pixel reconstruction.

Since the decoder is solely responsible for reconstruction,it is independent of the encoder design, making it flexible.

We compute loss only for masked patches, and use the MSE (mean squared error loss) in the pixel space between the input image and the reconstructed image.

Linear Probing and Full Fine-tuning

In linear probing, the pre-trained model is fixed, and only one linear layer is added at the end, to predict the labels (or produce the output). This method is used to assess the quality of representations from a pre-trained feature extraction model.

In fine-tuning, pre-trained model is further trained (not fixed), and one or more layers, possibly with non-linearities are added.

Contrastive Representation Learning

In contrastive representation, the transformed and the original image are marked as positive, while the other images are marked negative.

We want to get a score function:

score(f(x),f(x+))>>score(f(x),f(x−))score(f(x), f(x^+)) >> score(f(x), f(x^-))

Given a chosen score function, we aim to learn an encoder function ff that yields high score for positive pairs (x,x+)(x, x^+) and low scores for negative pairs (x,x−)(x, x^-) .

Loss function given 1 positive sample and N - 1 negative samples:

L=−EX[log⁡exp⁡(s(f(x),f(x+)))exp⁡(s(f(x),f(x+)))+∑j=1N−1exp⁡(s(f(x),f(xj−)))]L = -\mathbb{E}_X \left[ \log \frac{\exp(s(f(x), f(x^+)))}{\exp(s(f(x), f(x^+))) + \sum_{j=1}^{N-1} \exp(s(f(x), f(x_j^-)))} \right]

This is commonly known as the InfoNCE loss. It is a lower bound on the mutual information between f(x) and f(x+).

Typical Contrastive Learning models include SimCLR, MoCo, and DINO.