Lecture 11 · AI4ST

Transfer & Self-Supervised Learning

How to reuse knowledge across domains and learn from oceans of unlabeled sensor data: the transfer-learning taxonomy, fine-tuning & domain adaptation, and the self-supervised families (AutoEncoder, predictive, contrastive) that lead toward foundation models for Ambient Intelligence.

⏱ ~55 min 📚 6 sections ✅ 13 MCQ + 2 open-ended ⭐ Includes sim Q10 — the pretext-task question 🧠 Interactive mind map →
1

What is Transfer Learning?

Deep models need huge labeled datasets — but in Ambient Intelligence labels are scarce and expensive. Transfer Learning (TL) reuses knowledge learned on a data-rich source to boost a data-poor target.

Definition (Byrnes, 1996)
Transfer learning is the process of using knowledge gathered from solving one problem and applying it to a different (but related) problem. Goal: improve the performance of target learners on target domains by transferring knowledge from different but related source domains — reducing the dependence on target-domain labeled data.

The formal definitions — know the pieces

Sibling set — domain vs task
The exam loves to swap the components of these two definitions. A domain is about the data; a task is about the labels and the predictive function.
ConceptSlide definition
Domain DD = {𝒳, P(X)} — a feature space 𝒳 and a marginal probability distribution P(X) over the data X
Task TT = {𝒴, f(·)} — a label space 𝒴 and an objective predictive function f(·) (learned from training data, used to predict the label of new instances)
Transfer learningGiven a source domain DS / task TS and a target domain DT / task TT, improve the learning of fT(·) using the knowledge in DS, TS, where DS ≠ DT or TS ≠ TT

When does it work? — necessary factors

  • Sufficient domain similarity: source and target must be related — the knowledge has to be transferable (a connection between the tasks must exist).
  • Sufficient target data: at least a small amount of target data is needed to adapt the transferred knowledge.
The risk — negative transfer
If the domains are not similar enough (or target data is insufficient), transferring knowledge can hurt the target learner instead of helping it: this is negative transfer. TL is therefore not always beneficial.
2

The Transfer Learning Taxonomy

TL can be categorized from two complementary perspectives: what changes between source and target (problem perspective), and how the knowledge is transferred (solution perspective).

Problem perspective — what is transferred

Sibling set — the 3 settings by label availability
Tell them apart by two questions: are the source/target tasks the same? and are labels available in source/target?
SettingDefinition
Transductive TLSource and target tasks are the same, but the domains differ (labels available only in the source). → Domain Adaptation
Inductive TLThe target task is different from the source task (labels available in the target). → Multi-Task Learning (labels also in source) & Self-Taught Learning (no labels in source)
Unsupervised TLFocus on unsupervised tasks in the target domain (e.g., clustering, dimensionality reduction); no labels in source nor target

Solution perspective — how it is transferred

Sibling set — the 4 "what to transfer" categories
Each names a different object moved from source to target. This four-way list is exactly the kind the exam harvests into one MCQ.
CategoryWhat is transferred
Instance-based transferRe-weight labeled source instances so they fit the target distribution and can be reused for target training
Feature-based transferFind a good feature representation (latent features) that reduces the gap between source and target domains
Parameter-based transferTransfer knowledge at the model/parameter level (shared parameters or priors between source and target models)
Knowledge-based transferTransfer relational knowledge / rules among the data (a knowledge base relating source and target)

These can be supervised or unsupervised depending on label availability in the target.

3

TL Approaches: Data, Model, Domain Adaptation

Data-based transfer

Instance-based

  • Re-weight source instances by their relevance to the target, so labeled source data can be reused in target training

Feature-based

  • Learn latent features shared across domains. Symmetric: map both source and target into one common space. Asymmetric: transform the source features to match the target

Model-based transfer

Sibling set — the two control families
Both move knowledge through the model, but one tweaks the loss and the other tweaks the weights.
  • Model control: add terms acting on the model — regularizers, knowledge distillation, domain adaptation — to steer the target model with source knowledge.
  • Parameter control: directly control the parameters — the canonical case is fine-tuning.

Fine-tuning

Pre-train on large source Freeze the first layers (generic features) Fine-tune the last layers on small target data

The early layers learn generic, transferable features and are kept frozen; the final layers (closer to the output) are fine-tuned on the small target dataset. It is the simplest, most widely used form of parameter-based transfer.

Unsupervised Domain Adaptation (UDA)

The goal
Learn features that are domain-invariant (the model can't tell which domain a sample came from) and class-discriminative (still good for the classification task) — when the target domain has no labels.
  • A binary domain classifier D tries to predict whether a feature comes from the source or the target domain.
  • Training combines a Discrepancy Loss (push features to be domain-invariant — fool D) and a Classification Loss (keep features discriminative on the labeled source task).
  • In AmI: cross-subject / cross-environment / cross-position / cross-device / cross-domain transfer, e.g. GAN-based UDA for cross-subject HAR and domain adaptation in load disaggregation.
ThinkYou have a HAR model trained on young adults and want it to work on elderly users, for whom you have plenty of unlabeled accelerometer data but no labels. Which TL setting and approach fit, and what is the failure mode to watch for?
Answer: Same task (recognize the same activities) but a different domain (different gait/dynamics, no target labels) → this is transductive TL = Domain Adaptation, specifically Unsupervised Domain Adaptation since the target is unlabeled. Train for domain-invariant + class-discriminative features (a domain classifier + discrepancy loss alongside the source classification loss), or use a GAN-based UDA as in cross-subject HAR. Failure mode: if young and elderly motion patterns are too dissimilar (insufficient domain similarity), you risk negative transfer — the transferred knowledge hurts rather than helps.
4

Self-Supervised Learning

Definition — sim Q10 lives here
Self-Supervised Learning (SSL) is a special case of transfer learning where the source has no labels. The model is first trained on a pretext (upstream) task whose labels are automatically derived from the data itself; the resulting feature extractor is then transferred to the real downstream task (e.g., fine-tuned with a small labeled set).

Pretext task → downstream task

Pretext task on large unlabeled data (auto-generated labels) Reliable feature extractor Downstream task (small labeled set)
  • The pretext task is a supervised task — but the supervision (the labels) is extracted automatically from the unlabeled data, not provided by a human.
  • Its only role is to learn a good representation: a reliable feature extractor that leverages a large pool of unlabeled data.
  • Three big families (next section): AutoEncoder (generative), predictive, contrastive.
Exam trap — the supervised↔unsupervised swap
Sim Q10's wrong option calls the pretext task an unsupervised learning task. It is supervised — the trick is that its labels are auto-extracted from unlabeled data. SSL uses unlabeled data, but the pretext task itself is a supervised problem.
5

The Three Self-Supervised Families

Sibling set — AutoEncoder vs Predictive vs Contrastive
Three ways to invent a pretext task. Learn each by its one-line idea — the professor builds whole MCQs out of this triplet.
FamilyPretext idea & notes
AutoEncoderThe simplest: reconstruct the input x from a compressed latent code (dimensionality reduction). The least effective at learning rich representations
PredictiveMask part of the input and predict it (à la NLP / GPT). Cons: reasoning stays at the data level and the model learns a conservative distribution. Example: Masked AutoEncoder (MAE)
ContrastiveBuild similar (positive) and dissimilar (negative) pairs and use a distance-based loss to pull positives together and push negatives apart. Example: SimCLR

Contrastive learning — SimCLR

  • Apply two random augmentations to a sample → the two views form a positive pair; views of different samples form negative pairs.
  • An encoder (shared weights) maps views to features; a projection head maps them to the space where the contrastive loss (with temperature τ) is computed.
  • HAR-specific augmentations for sensor time series: Gaussian noise, scaling, 3D rotation, negation, time-flip, section scramble, time-warp, channel shuffle.

Triplet loss — another contrastive loss

Given three points — an anchor, a positive (a transformation of the anchor) and a negative (from another data point) — minimize the anchor↔positive distance and maximize the anchor↔negative distance, with a margin α enforcing a minimum gap.

Loss = Σi [ ‖fia − fip‖² − ‖fia − fin‖² + α ]+
The major challenge of contrastive learning
Choosing negative samples is not trivial. They are usually picked at random, but (1) sampling them from large unlabeled data is expensive, and (2) the most useful ones are hard negatives — samples that look close in the original space but should be pushed far apart.
6

SSL in Ambient Intelligence & Foundation Models

Self-supervised methods for sensor data

🌊

Wavelet contrastive

Positive = a raw signal & its wavelet scalogram; negative = scalogram of another window. A Siamese signal+scalogram network; only the signal net is kept for feature extraction.

📡

Multi-device contrastive

Several devices observe the same activity. Time-synchronized windows are positives; non-synchronized ones are negatives (CelloSSL-style).

🔮

Contrastive Predictive Coding

Pretext = predict future sensor points from past: an encoder builds z-vectors, an autoregressive model (LSTM) builds context vectors; future predictions minimize the L2 error.

🎭

Masked Reconstruction / MAE

Mask x% of samples and force the model to reconstruct them, learning temporal patterns from context; Spatio-Temporal MAE adds a device dimension.

Towards Foundation Models

What is a Foundation Model?
"Any model that is trained on broad data (generally using self-supervision) that can be adapted (e.g., fine-tuned) to a wide range of downstream tasks."

Broad pretraining

  • Trained on large and diverse datasets, using a general-purpose objective

Wide adaptability

  • Adaptable to a wide set of downstream tasks without re-training from scratch

The AmI arc: handcrafted features (2004) → deep learning (2013) → transfer & domain generalization (2016) → self-supervised learning (2019) → foundation models (2023). A recent example is Google's SensorLM, a FM over daily multimodal wearable data.

Bootstrapping models: SSL + active learning

  • When even a small labeled set for fine-tuning is unavailable, use the self-supervised model to cluster unlabeled target data — but the clusters still need labels.
  • SelfAct: labels for those clusters are obtained via active learning — a query is triggered when a new sample significantly changes its closest cluster. SSL pre-training + active learning bootstraps a personalized classifier with minimal user effort.

Final Quiz — Exam Style

13 MCQs + 2 open-ended. One is the actual simulation question (Q10) reproduced verbatim; the rest are built with the professor's recipe — sibling distractors, one-word swaps, a 2×2 grid, and a FALSE question hiding an absolutizer.

1
What is the main goal of Transfer Learning?
ATo compress a large model so it can run on a resource-constrained edge device
BTo continuously update a deployed model with mini-batches of new streaming data
CTo use knowledge gathered solving one problem to improve a target learner on a different but related problem
DTo train a single model on multiple sensors so it generalizes across modalities
C — the Byrnes definition: reuse knowledge from a (related) source to improve a target learner. A is model compression (Lecture 7b), B is incremental learning (Lecture 10), D is a plausible-sounding mutation. Cross-topic distractors are a favorite exam move.
2
In the formal definitions, a domain D is composed of:
AA feature space and a marginal probability distribution over the data
BA label space and an objective predictive function over the data
CA feature space and an objective predictive function over the data
DA label space and a marginal probability distribution over the data
AD = {𝒳, P(X)}: feature space + marginal distribution. B is the definition of a task T = {𝒴, f(·)} — the classic swap. C and D mix one piece of each (2×2 of the four building blocks). Domain = about the data; task = about the labels and the predictor.
3
In transductive transfer learning (e.g., domain adaptation):
AThe target task differs from the source task, and labels are available in the target domain
BThe source and target tasks are the same, but the domains differ and labels are only in the source
CThe target task is unsupervised, and no labels are available in source nor target
DThe source and target tasks are the same, and labels are available in both domains
B — transductive TL: same task, different domains, labels only in the source → domain adaptation. A describes inductive TL (different target task, target labels); C describes unsupervised TL. D is a fabricated mix. Sort the settings by "same task?" and "where are the labels?".
4
Which describes instance-based transfer (solution perspective)?
AFinding a good latent feature representation that reduces the gap between the two domains
BTransferring shared parameters or priors between the source and target models
CTransferring relational knowledge or rules among the data via a knowledge base
DRe-weighting labeled source instances so they can be reused to train on the target
D — instance-based = re-weight source instances. The distractors are its three siblings from the same slide: A = feature-based, B = parameter-based, C = knowledge-based. Each category names a different object transferred from source to target.
5
In feature-based transfer, what distinguishes the symmetric approach?
ABoth source and target features are mapped into a single common latent space
BOnly the source features are transformed to match the target feature space
COnly the target features are transformed to match the source feature space
DThe source instances are re-weighted and reused directly in the target space
Asymmetric: map both domains into one shared space. B is asymmetric (transform the source to the target). C inverts the asymmetric direction; D is instance-based, not feature-based. "Symmetric" = both sides move; "asymmetric" = one side moves.
6
How does fine-tuning typically reuse a model pre-trained on a large source dataset?
AIt re-weights the source samples and trains a brand-new model from scratch on them
BIt adds a domain classifier and a discrepancy loss to make the features domain-invariant
CIt freezes the early generic layers and trains only the last layers on the small target data
DIt keeps the previous model as a teacher generating pseudo-labels on the new data
C — fine-tuning is parameter-based transfer: early layers (generic features) stay frozen, the final layers are fine-tuned on the small target set. A is instance-based; B is UDA; D is LwF distillation from Lecture 10 — neighbouring mechanisms make the sharpest distractors.
7
What kind of features does Unsupervised Domain Adaptation aim to learn?
AFeatures that are domain-specific, so each domain keeps its own dedicated representation
BFeatures that are domain-invariant and, at the same time, class-discriminative
CFeatures that are class-invariant, so all activities share the same representation
DFeatures that are sparse, so only a few neurons activate per input sample
B — UDA wants features the domain classifier cannot attribute to a domain (domain-invariant) yet still good for the task (class-discriminative), trained with a discrepancy loss + a classification loss. A inverts the first goal, C corrupts the second (class-invariant would destroy the classifier), D is unrelated jargon.
8
Which of these sentences on transfer learning is FALSE?
AA sufficient similarity between the source and target domains is needed
BA sufficient amount of target data is needed to adapt the transferred knowledge
CIf the domains are not similar enough, transfer may degrade the target performance
DTransferring knowledge from any source domain always improves the target learner
D is FALSE — TL needs sufficient domain similarity and target data; otherwise it causes negative transfer (it can hurt the target). "any source … always improves" is the absolutized claim. A, B, C are true. Exam rule: in a FALSE question, hunt the option with only / always / never / any.
9
Simulation exam · Q10
What is a pretext task in Self-Supervised Learning?
AIt is task of fine-tuning a feature extractor on the target domain by using labeled data
BIt is a supervised learning task that uses labels automatically extracted from unlabeled data. Its role is to generate a reliable feature extractor leveraging a large pool of unlabeled data
CIt is an unsupervised learning task. Its role is to generate a reliable feature extractor leveraging a large pool of unlabeled data
DIt is the task of fine-tuning a feature extractor on the target domain by using unlabeled data
B — the pretext task is supervised, but its labels are automatically extracted from unlabeled data, and its purpose is to build a reliable feature extractor over a large unlabeled pool. C is the one-word-swap trap (supervised→unsupervised): SSL uses unlabeled data, yet the pretext problem itself is supervised. A and D confuse the pretext task with the downstream fine-tuning step.
10
Which describes a contrastive self-supervised approach?
ABuild similar and dissimilar pairs and use a distance-based loss to bring positives close and push negatives apart
BReconstruct the input from a compressed latent code, mainly for dimensionality reduction
CMask part of the input and train the model to predict the masked portion from the context
DRe-weight labeled source instances so they can be reused in the target domain
A — contrastive = positive/negative pairs + distance loss (SimCLR, triplet). Its siblings: B = AutoEncoder (reconstruct; least effective), C = predictive (mask & predict; MAE). D is instance-based TL — the wrong taxonomy entirely, a tempting cross-section distractor.
11
In SimCLR applied to sensor data, how is a positive pair formed?
ATwo windows recorded by two different devices observing the same activity at the same time
BA raw signal window and the wavelet scalogram computed from a different window
CTwo different random augmentations of the same input sample
DTwo windows belonging to two different activity classes in the labeled set
C — in SimCLR a positive pair = two augmented views of the same sample (Gaussian noise, scaling, rotation, time-warp…); views of different samples are negatives. A is the multi-device contrastive idea, B is the wavelet approach (and its negative uses a different window), D contradicts "self-supervised" by needing labels.
12
What does the triplet loss optimize, given an anchor, a positive and a negative example?
AIt reconstructs the anchor from the positive while ignoring the negative example
BIt maximizes the anchor–positive distance and minimizes the anchor–negative distance
CIt predicts the negative example from the anchor using an autoregressive model
DIt minimizes the anchor–positive distance and maximizes the anchor–negative distance, with a margin
D — pull the anchor and its positive together, push the anchor and the negative apart, with a margin α enforcing a minimum gap. B is the exact inversion of the two distances (the classic swap); A and C borrow vocabulary from the AutoEncoder and predictive families.
13
According to the lecture, what is a Foundation Model?
AA model trained on a single narrow task that reaches state-of-the-art accuracy on that task
BA model trained on broad data (generally self-supervised) that can be adapted to a wide range of downstream tasks
CA model whose weights are frozen and shipped to edge devices without any adaptation
DA small model distilled from a large teacher to run under tight resource budgets
B — the verbatim definition: broad pretraining (large, diverse data, general-purpose objective, usually self-supervised) + wide adaptability (adaptable to many downstream tasks without re-training from scratch). A contradicts "broad data", C contradicts "can be adapted", D is model compression again.
14
Open-ended · Transfer learning
a) Define transfer learning and its two categorization perspectives (problem and solution). What conditions must hold, and what is negative transfer?
b) Describe the main approaches: data-based (instance/feature, symmetric vs asymmetric), model-based (fine-tuning), and unsupervised domain adaptation.
Model answer

a) Transfer learning uses knowledge gathered solving one problem to improve a target learner on a different but related problem — transferring knowledge from data-rich source domains/tasks to a data-poor target. Formally, a domain is D = {𝒳, P(X)} (feature space + marginal distribution) and a task is T = {𝒴, f(·)} (label space + predictive function); TL applies when DS ≠ DT or TS ≠ TT. Problem perspective (what changes): transductive (same task, different domains, source-only labels → domain adaptation), inductive (different target task, target labels → multi-task & self-taught learning), unsupervised (unsupervised target task, no labels anywhere). Solution perspective (what to transfer): instance-based (re-weight source instances), feature-based (shared latent features), parameter-based (shared parameters/priors), knowledge-based (relational knowledge). Conditions: sufficient domain similarity and sufficient target data. If they don't hold, knowledge transfer can hurt the target — negative transfer — so TL is not always beneficial.

b) Data-based. Instance-based: re-weight labeled source instances by their relevance so they can be reused for target training. Feature-based: learn latent features that reduce the domain gap — symmetric maps both source and target into one common space, asymmetric transforms the source to match the target. Model-based. Model control adds regularizers / distillation / domain adaptation; parameter control = fine-tuning: pre-train on a large source, freeze the early (generic) layers and fine-tune the final layers on the small target dataset. Unsupervised Domain Adaptation: when the target has no labels, learn features that are domain-invariant (a binary domain classifier can't tell source from target — driven by a discrepancy loss) yet class-discriminative (a classification loss keeps them useful for the task). In AmI this enables cross-subject / cross-environment / cross-device transfer (e.g., GAN-based UDA for cross-subject HAR, domain adaptation in load disaggregation).

15
Open-ended · Self-supervised learning
a) What is self-supervised learning and what is a pretext task? Explain why the pretext task is supervised even though no human labels are used.
b) Describe the three SSL families (AutoEncoder, predictive, contrastive), the contrastive negative-sampling challenge, and how SSL leads toward foundation models / model bootstrapping in AmI.
Model answer

a) Self-supervised learning is a special case of transfer learning where the source data has no labels. The model is first trained on a pretext (upstream) task whose labels are automatically derived from the data itself; this builds a reliable feature extractor over a large unlabeled pool, which is then transferred to the real downstream task (e.g., fine-tuned with a small labeled set). The pretext task is a supervised learning problem — it has inputs and targets and is trained with a supervised loss — but the supervision is generated from the unlabeled data (e.g., the masked value to predict, or whether two views match) rather than provided by a human annotator. That is the subtle exam point: SSL uses unlabeled data, yet the pretext task itself is supervised (the sim-Q10 supervised↔unsupervised trap).

b) AutoEncoder (generative): reconstruct the input from a compressed latent code (dimensionality reduction) — the simplest and least effective at rich representations. Predictive: mask part of the input and predict it (NLP/GPT-style, e.g., the Masked AutoEncoder); cons: reasoning stays at the data level and the model learns a conservative distribution. Contrastive: form positive (similar) and negative (dissimilar) pairs and use a distance-based loss to pull positives together and push negatives apart — e.g. SimCLR (two augmented views of a sample are positives; an encoder + projection head feed a contrastive loss with temperature τ) and the triplet loss (anchor/positive/negative with a margin α). Challenge: choosing negative samples is hard — random sampling from large unlabeled data is expensive, and the most useful ones are hard negatives (look close in the original space but should be far apart). In AmI, SSL methods include wavelet/scalogram Siamese networks, multi-device time-synchronous contrastive learning, CPC and masked reconstruction. These point toward foundation models — trained on broad data with self-supervision and adaptable to many downstream tasks (e.g., SensorLM). When not even a small labeled set exists, SSL is combined with active learning to bootstrap a model (SelfAct: cluster the unlabeled data, then query labels when a sample significantly changes its closest cluster).

0/13
MCQ score 0/13