Difference between revisions of "Unsupervised Learning"

From David's Wiki
Jump to navigation Jump to search
(5 intermediate revisions by the same user not shown)
Line 186: Line 186:
 
* KL is always >= 0
 
* KL is always >= 0
 
* KL is not symmetric
 
* KL is not symmetric
 +
* Jensen-Shannon Divergence
 +
** <math>JSD(P \Vert Q) = \frac{1}{2}KL(P \Vert Q) + \frac{1}{2}KL(Q \Vert P)</math>
 +
** This is symmetric
  
 
====Model====
 
====Model====
Line 216: Line 219:
 
The main idea is to ensure the that discriminator is lipschitz continuous and to limit the lipschitz constant (i.e. the derivative) of the discriminator.<br>
 
The main idea is to ensure the that discriminator is lipschitz continuous and to limit the lipschitz constant (i.e. the derivative) of the discriminator.<br>
 
If the correct answer is 1.0 and the generator produces 1.0001, we don't want the discriminator to give us a very high loss.<br>
 
If the correct answer is 1.0 and the generator produces 1.0001, we don't want the discriminator to give us a very high loss.<br>
 +
====Earth mover's distance====
 +
{{main | wikipedia:earth mover's distance}}
 +
The minimum cost of converting one pile of dirt to another.<br>
 +
Where cost is the cost of moving (amount * distance)<br>
 +
Given a set <math>P</math> with m clusters and a set <math>Q</math> with n clusters:<br>
 +
...
 +
<math>EMD(P, Q) = \frac{\sum_{i=1}^{m}\sum_{j=1}^{n}f_{i,j}d_{i,j}}{\sum_{i=1}^{m}\sum_{j=1}^{n}f_{i,j}}</math><br>
 +
;Notes
 +
* Also known as Wasserstein metric
 +
 +
==Dimension Reduction==
 +
Goal: Reduce the dimension of a dataset.<br>
 +
If each example <math>x \in \mathbb{R}^n</math>, we want to reduce each example to be in <math>\mathbb{R}^r</math> where <math>r < n</math>
 +
===PCA===
 +
Principal Component Analysis<br>
 +
Preprocessing: Subtract the sample mean from each example so that the new sample mean is 0.<br>
 +
Goal: Find a vector <math>v_1</math> such that the projection <math>v_1 \cdot x</math> has maximum variance.<br>
 +
These principal components are the eigenvectors of <math>X^TX</math>.<br>
 +
 +
===Kernel PCA===
 +
===Autoencoder===

Revision as of 07:49, 4 December 2019

Basics of Unsupervised Learning

Clustering

Given points we wish to group them into clusters 1,...,k.
Usually we are given the number of clusters, k.
The problem is to assign labels where

K-means

Here we wish to cluster them to minimize the distance to the mean of their cluster.
In our formulation we have k clusters.
The mean of each cluster is called the centroid.</math>

Optimization

Let denote the centroids and let denote the cluster labels for our data.
Our loss function is .

Using coordinate-block descent

.
If we fix then we have only need to minimize .
Since each term of the sum is independent, we simply choose the closest centroid for each point
If we fix then we need to minimize wrt .
Taking the gradient and setting it to 0 we get:





Notes

This procedure will yield us a sequence of parameters and losses.


  • Since the loss is monotone decreasing and bounded below, it will converge by the monotone convergence theorem.
  • However, this does not imply that the parameters and will converge.

Algorithm

  1. Randomly initialize labels .
  2. Then calculate the centroids .
  3. Then update the labels for each example to the closest centroid.
  4. Update the centroids by taking the mean of every point in the cluster.
  5. Repeat steps 3 and 4

Soft K-means

We will develop a model for how our data is generated.
We will then find probabilities for each element being from a cluster (ala Bayesian paradigm).
Given clusters, the probability of a point being from cluster k is
We will assume each cluster is from a normal distribution

EM Algorithm

Expectation Maximization
The key idea is to introduce intermediate coefficients to apply Jensen's inequality.

Maximum Likelihood

Let denote our parameters.
The likelihood is where is our pdf/pmf.
Then the log-likelihood is
By introducing an extra variable we'll be able to apply Jensen's inequality to the concave log function.
Assume is a probability mass function.




Let
The EM algorithm is an iterative algorithm which alternates between an E-Step and an M-Step.

E-Step

We will fix and maximize J wrt .
Jensen's inequality holds with equality iff either the function is linear or if the random variable is degenerate.
We will assume is a constant.
This implies .
Since Q is a pmf, we have
Q is updated with

Maximization w.r.t Q


We are assuming that Q is a pmf so
Our lagrangian is:
We can maximize each independently.
Taking the derivative wrt Q we get:

</math>


Since Q is a pmf, we know it sums to 1 so we get the same result replacing with

M-Step

We will fix and maximize J wrt
Assume for simplicity.
Then






Maximizing wrt , we get .
Maximizing wrt we get

Maximization wrt phi

We want to maximize subject to the condition since is a pmf.
The lagrangian for this is
This can be rewritten as
The dual of this problem is
Taking the gradient w.r.t , we get
Plugging this into our dual problem we get:


Taking the derivative with respect to , we get:







Plugging in into our equation for we get

Generative Models

Goal: Generate realistic but fake samples. Applications: Denoising, impainting

VAEs

Variational Auto-Encoders
Tutorial

KL Divergence

Notes
  • KL is always >= 0
  • KL is not symmetric
  • Jensen-Shannon Divergence
    • This is symmetric

Model

Our model for how the data is generated is as follows:

  • Generate latent variables iid where dimension r is less than n.
    • We assume
  • Generate where
    • For some function parameterized by

Variational Bound

The variational bound is:

Derivation

We know from Baye's rule that .
Plugging this into the equation for yields our inequality.




Rearranging terms we get:

Since the KL divergence is greater than or equal to 0, our variational bound follows.

GANs

Wasserstein GAN

Paper
The main idea is to ensure the that discriminator is lipschitz continuous and to limit the lipschitz constant (i.e. the derivative) of the discriminator.
If the correct answer is 1.0 and the generator produces 1.0001, we don't want the discriminator to give us a very high loss.

Earth mover's distance

The minimum cost of converting one pile of dirt to another.
Where cost is the cost of moving (amount * distance)
Given a set with m clusters and a set with n clusters:
...

Notes
  • Also known as Wasserstein metric

Dimension Reduction

Goal: Reduce the dimension of a dataset.
If each example , we want to reduce each example to be in where

PCA

Principal Component Analysis
Preprocessing: Subtract the sample mean from each example so that the new sample mean is 0.
Goal: Find a vector such that the projection has maximum variance.
These principal components are the eigenvectors of .

Kernel PCA

Autoencoder