Skip to content

Instantly share code, notes, and snippets.

Avatar

Colin Raffel craffel

View GitHub Profile
@craffel
craffel / Tutorial.ipynb
Created Oct 21, 2017
pretty_midi tutorial (draft)
View Tutorial.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@craffel
craffel / gist:76924fd211720412c19327cfb8f0f5e2
Created Jun 21, 2017
Vim regex for replacing all commas not followed by space with commas followed by space
@craffel
craffel / Count github LOC.ipynb
Created Apr 24, 2016
Count your total contributions on GitHub of a certain filetype (a hack)
View Count github LOC.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@craffel
craffel / popcount_array.pyx
Last active May 9, 2019 — forked from aldro61/popcount_array.pyx
Popcount of a numpy array of integers of any dtype
View popcount_array.pyx
"""
Functions for computing the population count (aka Hamming weight) of an array
in-place using the built-in popcount routine.
Works with any integer datatype 64 bit-width or smaller.
Compile with gcc flag -mpopcnt
Adapted from
https://gist.github.com/aldro61/f604a3fa79b3dec5436a by Alexandre Drouin
"""
import numpy as np
cimport numpy as np
@craffel
craffel / mrr.py
Created Jan 19, 2016
Compute mean reciprocal rank between two sets of feature vectors
View mrr.py
def mean_reciprocal_rank(X, Y, indices, metric='hamming'):
''' Computes the mean reciprocal rank of the correct match
Assumes that X[n] should be closest to Y[n]
Default uses hamming distance
:parameters:
- X : np.ndarray, shape=(n_examples, n_features)
Data matrix in X modality
- Y : np.ndarray, shape=(n_examples, n_features)
Data matrix in Y modality
- indices : np.ndarray
@craffel
craffel / clean_clean_midis.py
Last active Apr 24, 2016
Scripts used for generating the clean MIDI subset, as used in https://github.com/craffel/midi-dataset
View clean_clean_midis.py
import os
os.chdir('..')
import sys
sys.path.append(os.getcwd())
import normalize_names
import pickle
with open('data/Clean MIDIs-md5_to_artist_title.pickle') as f:
md5_to_artist_title = pickle.load(f)
@craffel
craffel / get_live_uspop2002.py
Created Dec 2, 2015
Get liveness score for each entry in uspop2002
View get_live_uspop2002.py
"""
Create a tab-separated value file for uspop2002 entries which includes each
track's Echo Nest "loudness" score
"""
import pyen
import os
import time
# Put your Echo Nest API key in a file called .echonest_key
@craffel
craffel / Fast padding.ipynb
Created Nov 19, 2015
Faster 'same' mode convolutions in Lasagne, for even filter sizes too!
View Fast padding.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@craffel
craffel / whetlab_results.json
Created Jul 3, 2015
Hashing hyperparameter search result dump from Whetlab
View whetlab_results.json
This file has been truncated, but you can view the full file.
{
"description": "CQT no beats",
@craffel
craffel / gist:a90a8baff0377e7f9542
Created Jun 8, 2015
Dynamic time warping in Theano
View gist:a90a8baff0377e7f9542
'''
Dynamic time warping implementation in Theano
See also
https://github.com/astanway/theano-dtw
https://github.com/danielrenshaw/TheanoBatchDTW
'''
import theano
import theano.tensor as T
You can’t perform that action at this time.