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
| """ | |
| Generate data triples (x, y, z) for deterministic classification p(y | x; z) | |
| Generative story: | |
| Given: n_clusters; for each cluster: | |
| - a cluster center (mean) center[z] | |
| - a linear model y=sign(w[z] * x + b[z]) | |
| pick z from uniform Categorical(n_clusters) |
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
| # compare FY entmax losses with (log)-likelihood objectives | |
| # author: vlad niculae | |
| import numpy as np | |
| import torch | |
| import matplotlib.pyplot as plt | |
| from entmax import entmax_bisect, entmax_bisect_loss | |
| def main(alpha=1.5): |
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
| """ | |
| Check sampling from a sequential CRF model. | |
| - Code is for n_states=2 but the strategy is general. | |
| - TODO; cythonize or numbaize | |
| - TODO; write general impl for clarity | |
| """ | |
| # 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 |
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
| // 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
| 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
| # 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
| # 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
| # 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(): |