Skip to content

Instantly share code, notes, and snippets.

@antoinebrl
antoinebrl / knn-vectorized.py
Last active November 22, 2022 19:43
Vectorized K-nearest neighbors (no for-loop)
import numpy as np
from scipy.stats import mode
def euclidean_distance(x1, x2):
# x1 array of shape (N, D)
# x2 array of shape (N', D)
# output pairwise distances, array of shape (N, N')
return np.linalg.norm(x1[:, np.newaxis] - x2, axis=1)
@antoinebrl
antoinebrl / README.md
Last active April 21, 2024 08:59
Prepare ImageNet

Preparation of ImageNet (ILSVRC2012)

The dataset can be found on the official website if you are affiliated with a research organization. It is also available on Academic torrents.

This script extracts all the images and group them so that folders contain images that belong to the same class.

  1. Download the ILSVRC2012_img_train.tar and ILSVRC2012_img_val.tar
  2. Download the script wget https://gist.githubusercontent.com/antoinebrl/7d00d5cb6c95ef194c737392ef7e476a/raw/dc53ad5fcb69dcde2b3e0b9d6f8f99d000ead696/prepare.sh
  3. Run it ./prepare.sh
@iandanforth
iandanforth / fix.md
Created July 19, 2019 02:28
ModuleNotFoundError: No module named '_lzma'

If you see this error when trying to import pandas under osx 10.14 Mojave

ModuleNotFoundError: No module named '_lzma'

You may be missing the xz libraries (https://tukaani.org/xz/)

This may be corrected by using homebrew to install it.

@antoinebrl
antoinebrl / GoogleXSSChallenge-Solutions.md
Last active September 19, 2022 04:22
Google XSS Challenge - Solutions