Showing posts with label ML. Show all posts
Showing posts with label ML. Show all posts

Saturday, May 24, 2025

logit, sigmoid function, and probability

step-by-step through how the sigmoid function turns a logit into a probability, with both math and plain English at each step.


✅ Step 1: What is a logit?

The logit of a probability pp is defined as:

logit(p)=log(p1p)\text{logit}(p) = \log\left(\frac{p}{1 - p}\right)

This is called the log-odds, because it’s the natural log of the odds.


✅ Step 2: What if we are given the logit and want to get the probability?

Let’s say we are given a number xx, and we know it’s a logit.

That means:

x=log(p1p)x = \log\left(\frac{p}{1 - p}\right)

We want to solve for pp, the probability.


✅ Step 3: Exponentiate both sides

To get rid of the logarithm, we exponentiate both sides:

ex=p1pe^x = \frac{p}{1 - p}

This tells us the odds in terms of xx.


✅ Step 4: Solve for pp

Now we solve this equation for pp.

Start with:

ex=p1pe^x = \frac{p}{1 - p}

Multiply both sides by 1p1 - p:

ex(1p)=pe^x (1 - p) = p

Distribute the left-hand side:

exexp=pe^x - e^x p = p

Now get all the pp's on one side:

ex=p+expe^x = p + e^x p

Factor out pp on the right-hand side:

ex=p(1+ex)e^x = p(1 + e^x)

Now divide both sides by 1+ex1 + e^x:

p=ex1+exp = \frac{e^x}{1 + e^x}

✅ Step 5: Simplify into the sigmoid form

We now simplify that expression:

p=ex1+ex=11+exex=11+exp = \frac{e^x}{1 + e^x} = \frac{1}{\frac{1 + e^x}{e^x}} = \frac{1}{1 + e^{-x}}

That’s the sigmoid function:

p=σ(x)=11+exp = \sigma(x) = \frac{1}{1 + e^{-x}}

✅ Final Result

So if you’re given a logit value xx, the sigmoid function:

σ(x)=11+ex\sigma(x) = \frac{1}{1 + e^{-x}}

turns it into a probability p(0,1)p \in (0, 1).


🔁 Why this is useful

  • In logistic regression, we compute:

    x=wTx+b(a linear score)x = w^T x + b \quad \text{(a linear score)}
  • Then use the sigmoid to convert that score (logit) into a probability of class 1:

    p=11+exp = \frac{1}{1 + e^{-x}}

This way, the model’s output is interpretable as a probability — suitable for binary classification.

Let me know if you want a plot or visualization to make it even clearer!

Wednesday, June 26, 2024

TinyML and Efficient Deep Learning Computing

 

https://hanlab.mit.edu/courses/2023-fall-65940

Efficient AI Computing,
Transforming the Future.

TinyML and Efficient Deep Learning Computing

6.5940

Fall

2023

https://efficientml.ai

This course focuses on efficient machine learning and systems. This is a crucial area as deep neural networks demand extraordinary levels of computation, hindering its deployment on everyday devices and burdening the cloud infrastructure. This course introduces efficient AI computing techniques that enable powerful deep learning applications on resource-constrained devices. Topics include model compression, pruning, quantization, neural architecture search, distributed training, data/model parallelism, gradient compression, and on-device fine-tuning. It also introduces application-specific acceleration techniques for large language models and diffusion models. Students will get hands-on experience implementing model compression techniques and deploying large language models (Llama2-7B) on a laptop.

  • Time:

    Tuesday/Thursday 3:35-5:00pm Eastern Time

  • Location:
    36-156
  • Office Hour:

    Thursday 5:00-6:00 pm Eastern Time, 38-344 Meeting Room

  • Discussion:
    Piazza
  • Homework Submission:
    Canvas
  • Contact:
    • For external inquiries, personal matters, or emergencies, you can email us at efficientml-staff [at] mit.edu.
    • If you are interested in getting updates, please sign up here to join our mailing list to get notified!

Instructor

Associate Professor

Teaching Assistants

Announcements

  • 2023-12-14

    Final report and course evaluation due

  • 2023-10-31

    Lab 5 is out.

Schedule

Date

Lecture

Logistics

Sep 7

Lecture 
1

Introduction

Sep 12

Lecture 
2

Basics of Deep Learning

Chapter I: Efficient Inference

Sep 14

Lecture 
3

Pruning and Sparsity (Part I)

Sep 19

Lecture 
4

Pruning and Sparsity (Part II)

Sep 21

Lecture 
5

Quantization (Part I)

Lab 0 due

Sep 26

Lecture 
6

Quantization (Part II)

Sep 28

Lecture 
7

Neural Architecture Search (Part I)

Lab 1 due (extended to Sep 30 at 11:59 p.m)

Lab 2 out

Oct 3

Lecture 
8

Neural Architecture Search (Part II)

Oct 5

Lecture 
9

Knowledge Distillation

Oct 10

Student Holiday — No Class

Oct 12

Lecture 
10

MCUNet: TinyML on Microcontrollers

Lab 2 due

Oct 17

Lecture 
11

TinyEngine and Parallel Processing

Chapter II: Domain-Specific Optimization

Oct 19

Lecture 
12

Transformer and LLM (Part I)

Lab 3 due, Lab 4 out

Oct 24

Lecture 
13

Transformer and LLM (Part II)

Oct 26

Lecture 
14

Vision Transformer

Project ideas out (on Canvas)

Oct 31

Lecture 
15

GAN, Video, and Point Cloud

Lab 4 due, Lab 5 out

Nov 2

Lecture 
16

Diffusion Model

Chapter III: Efficient Training

Nov 7

Lecture 
17

Distributed Training (Part I)

Nov 9

Lecture 
18

Distributed Training (Part II)

Nov 14

Lecture 
19

On-Device Training and Transfer Learning

Lab 5 due

Nov 16

Lecture 
20

Efficient Fine-tuning and Prompt Engineering

Nov 21

Lecture 
21

Basics of Quantum Computing

Project proposal due

Nov 23

Thanksgiving — No Class

Chapter IV: Advanced Topics

Nov 28

Lecture 
22

Quantum Machine Learning

Nov 30

Lecture 
23

Noise Robust Quantum ML

Dec 5

Lecture 
24

Final Project Presentation

Dec 7

Lecture 
25

Final Project Presentation

[Slides]
[Video]
[Video (Live)]

Dec 12

Lecture 
26

Final Project Presentation + Course Summary

[Slides]
[Video]
[Video (Live)]

Dec 14: Project report and course evaluation due

Course Videos

Lecture 
1

Introduction

Lecture 
12

Transformer and LLM (Part I)

Lecture 
13

Transformer and LLM (Part II)

Lecture 
16

Diffusion Model