Hi guys,
Here are some demos of how to implement the EM algorithm in Pytorch.
If anyone has also done this, would be super interested to see different takes on it.

  
      gist.github.com
  
  
    https://gist.github.com/DuaneNielsen/45ac9f3a70cb6091a38984c35e372e6a 289
em_algo_2D.py
import torch
from torch import tensor
from torch.distributions.multivariate_normal import MultivariateNormal
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
import matplotlib.patches as mpatches
from math import acos, degrees
from matplotlib.pyplot import cm

"""
This file has been truncated. show original




  
  
    
    
  
  


1D example

  
      gist.github.com
  
  
    https://gist.github.com/DuaneNielsen/8c5bde8d35a46d60640d0579d913dcff 294
em_algo.py
import torch
from torch.distributions.normal import Normal
import matplotlib.pyplot as plt

"""
EM algo demo, in pytorch

"""

n = 40 # must be even number
This file has been truncated. show original