Skip to content

Instantly share code, notes, and snippets.

View gwgundersen's full-sized avatar

Gregory Gundersen gwgundersen

View GitHub Profile
@gwgundersen
gwgundersen / viz_mvn.py
Created April 26, 2020 16:44
Visualizing a multivariate Gaussian distribution
# Because I always forget how to do this.
#
# Credit: https://scipython.com/blog/visualizing-the-bivariate-gaussian-distribution/
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D
from scipy.stats import multivariate_normal
@gwgundersen
gwgundersen / celebaae.py
Created November 15, 2019 17:47
Autoencoder based on CelebA-based VAE
"""=============================================================================
Autoencoder based on "vanilla_ae" that has good results on CelebA:
Credit: https://github.com/bhpfelix/Variational-Autoencoder-PyTorch
============================================================================="""
from torch import nn
from torch.nn import functional as F
# ------------------------------------------------------------------------------
@gwgundersen
gwgundersen / contour_2d_gaussian.py
Created November 12, 2019 18:41
Contour plot of 2D gaussian
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import multivariate_normal
N = 200
X = np.linspace(-4, 4, N)
Y = np.linspace(-4, 4, N)
X, Y = np.meshgrid(X, Y)
pos = np.dstack((X, Y))
@gwgundersen
gwgundersen / marathon-app-definition.json
Last active August 24, 2016 14:22
Marathon app definition
{
"id": "/myapp",
"cmd": null,
"cpus": 1,
"mem": 4096,
"disk": 0,
"instances": 1,
"constraints": [
[
"hostname",
"""-------------------------------------------------------------------------------
- Use docstrings (https://www.python.org/dev/peps/pep-0008/#documentation-strings)
to describe each function at a high level. They are not always required, but I
think it's a good habit to write them.
- Internal functions should be prefixed with a single underscore
(https://www.python.org/dev/peps/pep-0008/#id41).
- `_url_encode` - I would not put implementation details in the a comment
describing the function. The user of a function should not care *how* the URL
from collections import namedtuple
import re
import pdb
# http://tools.ietf.org/html/rfc3986#section-3.3
"""
>> c = request.urlparse("http://gregorygundersen.com")
>> c
ParseResult(scheme='http', netloc='gregorygundersen.com', path='', params='', query='', fragment='')
"""