Skip to content

Instantly share code, notes, and snippets.

View jgraving's full-sized avatar

Jake Graving jgraving

  • Max Planck Institute of Animal Behavior
  • Konstanz, Germany
View GitHub Profile
@jgraving
jgraving / angleLerp.js
Created December 20, 2016 22:18 — forked from shaunlebron/angleLerp.js
The best way to interpolate 2D angles
/*
2D Angle Interpolation (shortest distance)
Parameters:
a0 = start angle
a1 = end angle
t = interpolation factor (0.0=start, 1.0=end)
Benefits:
1. Angles do NOT need to be normalized.
@jgraving
jgraving / BlahutArimoto.m
Created April 4, 2017 10:20 — forked from Piyush3dB/BlahutArimoto.m
Blahut-Arimoto algorithm implementation in Matlab
function [C r] = BlahutArimoto(p)
disp('BlahutArimoto')
% Capacity of discrete memoryless channel
% Blahut-Arimoto algorithm
% Input
% p: m x n matrix
% p is the transition matrix for a channel with m inputs and n outputs
@jgraving
jgraving / medfilt.py
Created July 31, 2017 14:33 — forked from bhawkins/medfilt.py
1D median filter using numpy
#!/usr/bin/env python
import numpy as np
def medfilt (x, k):
"""Apply a length-k median filter to a 1D array x.
Boundaries are extended by repeating endpoints.
"""
assert k % 2 == 1, "Median filter length must be odd."
@jgraving
jgraving / ffmpeg_load_audio.py
Created September 28, 2017 23:07 — forked from kylemcdonald/ffmpeg_load_audio.py
Load audio from ffmpeg into Python using numpy.
import numpy as np
import subprocess as sp
import os
DEVNULL = open(os.devnull, 'w')
# load_audio can not detect the input type
def ffmpeg_load_audio(filename, sr=44100, mono=False, normalize=True, in_type=np.int16, out_type=np.float32):
channels = 1 if mono else 2
format_strings = {
np.float64: 'f64le',
@jgraving
jgraving / autoencoder_extra.py
Created December 7, 2017 13:36 — forked from njellinas/autoencoder_extra.py
Two Keras Layer-Class definitions for implementing Weight-Tying and for loading pretrained weights in Deep Autoencoders
import keras.backend as K
from keras.layers import Layer
from keras.legacy import interfaces
from keras.engine import InputSpec
from keras import activations, initializers, regularizers, constraints
class DenseTransposeTied(Layer):
@interfaces.legacy_dense_support
@jgraving
jgraving / algorithms_openpose.md
Created May 2, 2018 12:55 — forked from alesolano/algorithms_openpose.md
OpenPose TensorFlow Alogrithms
@jgraving
jgraving / Readme.md
Created May 24, 2018 12:53 — forked from dpatschke/Readme.md
Numba Ball Tree (ParallelAccelerator)

Numba Ball Tree (ParallelAccelerator)

This is a modified gist of Jake Vanderplas wonderful Numba Ball Tree code from the following gist. This gist basically adds the 'nopython' parameter in the jit decorators from the original gist and parallelizes the nearest neighbor query for each of the points.

Timings

With some of the new advances in numba and the modifications

@jgraving
jgraving / cuda_installation_on_ubuntu_18.04
Created September 25, 2018 09:39 — forked from Mahedi-61/cuda_11.8_installation_on_Ubuntu_22.04
cuda 9.0 complete installation procedure for ubuntu 18.04 LTS
#!/bin/bash
## This gist contains step by step instructions to install cuda v9.0 and cudnn 7.2 in ubuntu 18.04
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
@jgraving
jgraving / dtw_mse.py
Created April 10, 2019 22:56 — forked from kylemcdonald/dtw_mse.py
DTW MSE numba function for use with UMAP.
# based on https://github.com/kylerbrown/ezdtw
# with modifications to be fully njit-able
import numpy as np
from numba import njit
@njit
def sqeuclidean(a, b):
return np.sum((a - b)**2)
@jgraving
jgraving / Earth Mover's Distance.ipynb
Created April 10, 2019 22:56 — forked from kylemcdonald/Earth Mover's Distance.ipynb
Faster 1d Earth Mover's Distance with numpy and numba.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.