Skip to content

Instantly share code, notes, and snippets.

View tabacof's full-sized avatar

Pedro Tabacof tabacof

View GitHub Profile
@tabacof
tabacof / vae_mlp.py
Last active October 20, 2022 01:04
Variational Auto-Encoder (MLP encoder/decoder)
# -*- coding: utf-8 -*-
"""
Reproducing the results of Auto-Encoding Variational Bayes by Kingma and Welling
With a little help from the code from van Amersfoort and Otto Fabius (https://github.com/y0ast)
@author: Pedro Tabacof (tabacof at gmail dot com)
"""
import random
import numpy as np
# -*- coding: utf-8 -*-
import numpy as np
from scipy.special import binom
#Jaynes' PT:TLoS exercise 4.2
def db(x): # Decibel transform
return 10.0*np.log10(x)
def evidence(x): # Equation 4.8
# -*- coding: utf-8 -*-
import numpy as np
from scipy.special import binom
import random
#Jaynes' PT:TLoS exercise 4.4
def db(x): # Decibel transform
return 10.0*np.log10(x)
# -*- coding: utf-8 -*-
import numpy as np
import pylab
from scipy.special import binom
from bayespy.nodes import Categorical, Binomial, Gate, Beta
#Jaynes' PT:TLoS example 4.1
def db(x): # Decibel transform
return 10.0*np.log10(x)
# -*- coding: utf-8 -*-
import numpy as np
import pymc #2.3
import pylab
from scipy.special import binom
#Jaynes' PT:TLoS example 4.1
def db(x): # Decibel transform
return 10.0*np.log10(x)
# Jaynes' counter-intuitive equation
# 3.59 in PT:TLoS
import random
random.seed(1) # For experiment reproduction
# P(R1|R2)
count_reds1 = 0.0
count_total1 = 0.0
@tabacof
tabacof / lasso.py
Last active August 29, 2015 14:14
Lasso in PyMC3
from pymc import *
from scipy.stats import norm
import pylab as plt
# Same model as the tutorial
n = 1000
x1 = norm.rvs(0, 1, size=n)
x2 = -x1 + norm.rvs(0, 10**-3, size=n)
x3 = norm.rvs(0, 1, size=n)