This is some superscript text.
This file contains hidden or 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 os | |
import scipy.io.wavfile as wav | |
# install lame | |
# install bleeding edge scipy (needs new cython) | |
fname = 'XC135672-Red-winged\ Blackbird1301.mp3' | |
oname = 'temp.wav' | |
cmd = 'lame --decode {0} {1}'.format( fname,oname ) | |
os.system(cmd) | |
data = wav.read(oname) | |
# your code goes here |
This file contains hidden or 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
""" | |
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy) | |
BSD License | |
""" | |
import numpy as np | |
# data I/O | |
data = open('input.txt', 'r').read() # should be simple plain text file | |
chars = list(set(data)) | |
data_size, vocab_size = len(data), len(chars) |
This file contains hidden or 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
from tensorflow.python.client import device_lib | |
def get_available_gpus(): | |
local_device_protos = device_lib.list_local_devices() | |
return [x.name for x in local_device_protos if x.device_type == 'GPU'] | |
get_available_gpus() |
This file contains hidden or 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
""" | |
Python is a dynamic language, and it is relatively easy to dynamically create | |
and modify things such as classes and objects. Functions, however, are quite | |
challenging to create dynamically. | |
One area where we might want to do this is in an RPC library, where a function | |
defined on a server needs to be available remotely on a client. | |
The naive solution is to simply pass arguments to a generic function that | |
accepts `*args` and `**kwargs`. A lot of information is lost with this approach, |
This is a short post that explains how to write a high-performance matrix multiplication program on modern processors. In this tutorial I will use a single core of the Skylake-client CPU with AVX2, but the principles in this post also apply to other processors with different instruction sets (such as AVX512).
Matrix multiplication is a mathematical operation that defines the product of
Here is my to-do list for Gists/things I intend to write Gists about:
- Generic Bayesian linear regression: as basis functions, define some classes with
__call__
methods (EG Gaussian, polynomials) which take appropriate parameters to their__init__
method (EG location, scale, polynomial order); a given Bayesian linear regression solution should accept a list of basis functions, whose outputs for each data point can be calculated with the built-inmap
function, ornumpy.vectorise
, and compare the output with the MAP and ML solutions, EG:
import numpy as np
class Sigmoid:
def __init__(self, loc): self.loc = loc
def __call__(self, x): return 1.0 / (1.0 + np.exp(self.loc - x))
Shown below is some code to perform generic speed tests and save a log-log graph of the results (in this example, eigenvalue decomposition for SPD matrices is being tested). The resulting graph is shown below the code:
import numpy as np
import matplotlib.pyplot as plt
import scipy as sp
from time import perf_counter
OlderNewer