This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # author: vn | |
| import numpy as np | |
| from scipy.optimize import root_scalar | |
| import torch | |
| import matplotlib.pyplot as plt | |
| def entropy(y, a, b): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://arxiv.org/abs/2002.08676 | |
| # code by vlad niculae | |
| # license: mit | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| def main(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |