View hyperbolic.py
This file contains 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
"""wrapped hyperbolic distributions | |
following https://arxiv.org/abs/1902.02992 | |
""" | |
# author: vlad niculae <v.niculae@uva.nl> | |
# license: bsd 3-clause | |
import torch |
View check_det_without_rotat.py
This file contains 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
""" trying to understand the determinant of sphere-to-cyl """ | |
import numpy as np | |
import jax.numpy as jnp | |
from jax import jacfwd | |
# map from cylinder to sphere | |
def phi(zr): | |
d = zr.shape[0] |
View kl.py
This file contains 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
""" | |
Approximating the cross-entropy between two Power Sphericals. | |
Uses a second-order Taylor expansion to approximate E[log(1+z)]. | |
""" | |
# author: vlad n <vlad@vene.ro> | |
# license: mit | |
# documentation: https://hackmd.io/@vladn/SJ93wMevK |
View plot_dual_norms.py
This file contains 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
""" | |
Dual p-norms illustrated. | |
For any norm |.|, the dual norm is defined as |y|_* = max{ <x, y> for |x| <= 1 }. | |
The figure shows the unit balls of the p-norm, for p = 1.5, 2, and 3. | |
We compute the dual norm at a dual vector y (short black arrow), rotating | |
uniformly around the origin over time. |
View multi_mixins.py
This file contains 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
class Base: | |
def say(self, val): | |
print("base says", val) | |
class A(Base): | |
def say(self, val): | |
print("say A") |
View README.txt
This file contains 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
Example input and output. | |
$ python conf.py seed=42 lr=.1 | |
project: ??? | |
seed: 42 | |
lr: 0.1 | |
epochs: ??? | |
p_drop: 0.5 | |
baseconf: null |
View decision_boundary.py
This file contains 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 |
View soft_box.py
This file contains 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): |
View energy.py
This file contains 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 |
View check_spherical_jacob_tangent.py
This file contains 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(): |
NewerOlder