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
% Read a set of vectors stored in the fvec format (int + n * float) | |
% The function returns a set of output vector (one vector per column) | |
% | |
% Syntax: | |
% v = fvecs_read (filename) -> read all vectors | |
% v = fvecs_read (filename, n) -> read n vectors | |
% v = fvecs_read (filename, [a b]) -> read the vectors from a to b (indices starts from 1) | |
function v = fvecs_read (filename, bounds) | |
% open the file and count the number of descriptors |
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
"""Usage: | |
python aggregate_tree.py 500000 | |
python aggregate_tree.py -3000 | |
""" | |
from matplotlib import pyplot as plt | |
import numpy as np | |
import pdb |
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
import numpy as np | |
import pdb | |
from sklearn.datasets import make_classification | |
from sklearn.mixture import GaussianMixture as GMM | |
def fisher_vector(xx, gmm): | |
"""Computes the Fisher vector on a set of descriptors. |
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
import numpy as np | |
def power_normalize(xx, alpha=0.5): | |
"""Computes a alpha-power normalization for the matrix xx.""" | |
return np.sign(xx) * np.abs(xx) ** alpha | |
def L2_normalize(xx): | |
"""L2-normalizes each row of the data xx.""" |
NewerOlder