Skip to content

Instantly share code, notes, and snippets.

Avatar
🏴
ahoy

Vlad Niculae vene

🏴
ahoy
View GitHub Profile
View decision_boundary.py
# author: vlad niculae <vlad@vene.ro>
# license: mit
import torch
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from entmax import sparsemax, entmax15
from entmax.losses import sparsemax_loss, entmax15_loss
View soft_box.py
# author: vn
import numpy as np
from scipy.optimize import root_scalar
import torch
import matplotlib.pyplot as plt
def entropy(y, a, b):
@vene
vene / energy.py
Created Oct 19, 2020
energy model with langevin dynamics
View energy.py
# Density estimation with energy-based models
# Langevin sampling, contrastive divergence training.
# Author: Vlad Niculae <vlad@vene.ro>
# License: MIT
import numpy as np
import torch
from sklearn import datasets
import matplotlib.pyplot as plt
View check_spherical_jacob_tangent.py
# Geometric intepretation of the gradient of the mapping:
# f : (0, inf) x Sphere(k-1) -> R^k
# f(r, u) -> r*u
# The *catch*: R can vary on (0, inf) but u may only vary on the
# k-1--dimensional tangent plane!
import numpy as np
def main():
View check_mixture.py
# linearity of expectation under mixture model
# license: mit
# author: vlad niculae
from scipy.stats import norm
import numpy as np
def main():
rng = np.random.RandomState(42)
@vene
vene / check_berthet_gradients.py
Created Jun 22, 2020
check mc perturbed gradients (Berthet et at)
View check_berthet_gradients.py
# https://arxiv.org/abs/2002.08676
# code by vlad niculae
# license: mit
import numpy as np
import matplotlib.pyplot as plt
def main():
@vene
vene / merge.sh
Created Jun 17, 2020
merge slideslive
View merge.sh
ffmpeg \
-i slideslive-recorder_[...].364Z_user.webm \
-i slideslive-recorder_[...].364Z_display.webm \
-filter_complex \
'[0:v]scale=640:360,pad=640:720[left];[1:v]crop=1680:945:0:0,scale=1280:720[right];[left][right]hstack[v]' \
-map [v] \
-map 0:a \
-c:v libx264 \
-preset veryslow \
-crf 18 \
View binary_kbest.h
// k-best assignments for independent binary variables
// (optimized version of zeroth order viterbi)
// author: vlad niculae <vlad@vene.ro>
// license: mit
#pragma once
#include <vector>
#include <algorithm>
#include <cassert>
#include <bitset>
@vene
vene / bernoulli.py
Last active Apr 16, 2020
Sum-and-sample estimator for learning a stochastic Bernoulli.
View bernoulli.py
"""Sum-and-sample estimator for learning a stochastic Bernoulli.
Reproduces Experiment 1 from
Liu et al, Rao-Blackwellized Stochastic Gradients for Discrete Distributions
https://arxiv.org/abs/1810.04777
"""
# author: vlad niculae <vlad@vene.ro>
# license: mit
@vene
vene / sphere_barycenter.py
Created Apr 6, 2020
barycenter on sphere
View sphere_barycenter.py
# author: vlad niculae <vlad@vene.ro>
# license: mit
import numpy as np
from scipy.special import softmax
from mayavi import mlab
def barycenter(X, w):
# riemannian opt
You can’t perform that action at this time.