๐Ÿ”ฅLimited Offer: Get 50% OFFon AI & Full Stack Courses๐Ÿ”ฅ
Back to Deep Learning Notes
Topic #38

Probability Distributions

A probability distribution is the complete rule describing how likely each possible value of a random variable is. Knowing which distribution a network's output represents tells you exactly which loss function to use.

Discrete: Probability Mass Function (PMF)

\[ P(X = x) \ge 0, \qquad \sum_x P(X=x) = 1 \]

The Bernoulli distribution (a single yes/no outcome, e.g. binary classification) is the most common discrete distribution in deep learning: \(P(X=1)=p\), \(P(X=0)=1-p\). The categorical distribution generalizes this to more than two outcomes โ€” exactly what a softmax output represents.

Continuous: Probability Density Function (PDF)

\[ f(x) \ge 0, \qquad \int_{-\infty}^{\infty} f(x)\,dx = 1 \]

For continuous variables, \(f(x)\) is a density, not a probability directly โ€” \(P(a \le X \le b) = \int_a^b f(x)\,dx\) is the probability of landing in a range. The most important continuous distribution in deep learning is the normal (Gaussian) distribution:

\[ f(x) = \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{(x-\mu)^2}{2\sigma^2}} \]

\(\mu\) is the mean (center), \(\sigma\) is the standard deviation (spread). Weight initialization schemes (He, Xavier) sample from a normal distribution with a carefully chosen \(\sigma\).

Visualizing the Normal Distribution

μ (mean) larger σ smaller σ

A larger standard deviation σ spreads the distribution out; a smaller one concentrates it tightly around the mean μ.

Code

import numpy as np
import torch

# Sampling from a normal distribution -- common for weight initialization
samples = np.random.normal(loc=0.0, scale=0.05, size=5)
print(samples)

# PyTorch's default initialization for many layers uses a similar approach
layer = torch.nn.Linear(10, 5)
print(layer.weight.std().item())   # a small standard deviation, by design

Where This Shows Up in Deep Learning

DistributionDL Use Case
BernoulliBinary classification output, dropout mask
CategoricalMulti-class classification output (softmax)
Normal (Gaussian)Weight initialization, noise in VAEs and diffusion models
UniformSome weight initialization schemes, random data augmentation parameters

Common Mistakes

  • Treating a PDF value \(f(x)\) as a probability directly โ€” for continuous distributions, only the integral over a range gives a probability; \(f(x)\) itself can even exceed 1.
  • Assuming every network output is naturally categorical โ€” regression outputs are typically modeled as continuous (often implicitly Gaussian, which is why mean squared error is the natural loss โ€” see Mean Squared Error).

Interview Relevance

Q: "Why is a network's classification output modeled as a categorical distribution, but a regression output usually isn't?" Classification has a finite, discrete set of possible labels, matching the categorical distribution's support exactly (softmax enforces this). Regression targets are continuous, so they're typically modeled as coming from a continuous distribution (often implicitly Gaussian), which is what makes squared-error loss the natural choice.

Practice Question

A weight initialization scheme samples from a normal distribution with \(\mu=0, \sigma=0.01\). What does a small \(\sigma\) tell you about the typical initial weight values?

Want to go beyond the notes?

Join CodingNow 2.0's Deep Learning course โ€” live mentorship, real projects, and 100% placement support.

Enroll Now โ€” Free Demo Available

Probability Distributions โ€“ FAQs

Quick answers about learning Probability Distributions in Deep Learning.

This free note from CodingNow 2.0 explains Probability Distributions in Deep Learning โ€” concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Deep Learning topic on CodingNow 2.0, including Probability Distributions, is 100% free with no signup required.
With focused practice, most students grasp Probability Distributions in 1โ€“3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) โ€” expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now