Updating models without collecting raw data: FedAvg, heterogeneity challenges and the limits of privacy.
Advanced11 min read
Educational draft content that needs expert review before it is used as an academic reference. Specifications, versions and licences change; check the official source. No experimental result is shown here unless it was actually run.
Learning objectives
Explain the FedAvg algorithm
Describe the non-IID challenge
Understand the privacy limits of federated learning
In federated learning each device trains a copy of the model on its local data and sends only the weight update to a server that aggregates updates. The classic FedAvg algorithm computes a weighted average by each client’s sample count: w ← Σ (nₖ / n) · wₖ.
Challenges: data is non-IID across devices, connectivity is intermittent and device resources are limited. Although raw data is not sent, updates can leak information, so techniques such as secure aggregation and differential privacy are used; they improve protection but do not guarantee it absolutely.
On-device learning is harder than inference because training needs more memory and energy, so it is often used to fine-tune a few layers or small models. This module is theoretical; the lab contains no real federated-training experiment.
Terminology (with Arabic equivalents)
Federated learning
التعلم الاتحادي
FedAvg
متوسط اتحادي
Non-IID
بيانات غير متجانسة
Secure aggregation
تجميع آمن
Differential privacy
خصوصية تفاضلية
Worked example
Three clients with 100, 300 and 600 samples and resulting weights w₁, w₂, w₃: the server computes 0.1·w₁ + 0.3·w₂ + 0.6·w₃. The client with the most data has more influence.
Code snippet
PythonSimplified FedAvg
import numpy as np
def fedavg(weights, counts):
n = sum(counts)
return sum(w * (c / n) for w, c in zip(weights, counts))
w = [np.array([1.0, 2.0]), np.array([2.0, 0.0]), np.array([0.0, 1.0])]
print(fedavg(w, [100, 300, 600]))
An illustrative snippet that was not executed in the lab environment; check library versions in their official documentation before use.
Check yourself
What does a client send in federated learning?
Its raw data
A weight update
Screenshots
Passwords
Answer and explanation
A weight update — It sends an update computed locally, not the data.
By what is each client weighted in FedAvg?
By its number of samples
By screen size
By device age
No weighting
Answer and explanation
By its number of samples — It is weighted in proportion to its number of samples.
Does federated learning guarantee absolute privacy?
Yes
No; updates may reveal information
Yes, if the model is small
It sends nothing
Answer and explanation
No; updates may reveal information — Secure aggregation and differential privacy are needed, and there is no absolute protection.
McMahan et al. (2017). Communication-Efficient Learning of Deep Networks from Decentralized Data. AISTATSNot verified
Image and audio processing in the experiments runs inside your browser. Your images and audio are never uploaded and conversations are not stored. Privacy
Assistant Professor of Artificial Intelligence and Deep Learning
University of Al-Qadisiyah
About
Researcher and academic specialising in artificial intelligence (AI), deep learning, computer vision and natural language processing (NLP). The “Deep Learning in Arabic” project aims to enrich Arabic scientific and technical content with sound, free references and software for researchers and learners across the Arab world.
Edge AI Assistant
I am the Edge AI Assistant. Ask about a concept, technology, board or project and I will answer from the lab content with links.
Edge AI Assistant
Local Database Mode
Answers from the lab knowledge base only, without sending your question to any external party. Conversations are not stored.
Smart assistant
Answers from the site’s content
The assistant can make mistakes, so check the attached sources.
Welcome! I am Dr. Alaa Taima, and this is my smart assistant on “Deep Learning in Arabic”. Ask it about any term or topic in artificial intelligence, and it will answer from the site's content with links to the sources.
DL Bot
Your smart assistant · Connecting…
Enter to send · Shift + Enter for a new line · The assistant can make mistakes, so check the sources.