Skip to content

Instantly share code, notes, and snippets.

@preetum
preetum / bandstop.py
Last active December 29, 2015 16:49
Simple multi-bandstop filter
import pylab as plt
import numpy as np
import scipy.signal as ss
from scipy.io import wavfile
from math import pi
"""
A program that applies a multi-bandstop filter to a waveform
(eg, to filter out beeps)
@preetum
preetum / z3color.py
Created January 23, 2014 01:53
Determines the chromatic number of graphs (and their coloring), using Microsoft's Z3 SMT solver.
## This script uses Microsoft's Z3 SMT solver
## to determine the chromatic number (and corresponding coloring) of graphs.
##
## Author: Preetum Nakkiran, 2014
from z3 import *
def color(V, E, k):
"""
Attempt to color the graph G(V, E) with k colors
import numpy as np
from numpy import linalg
def null(A, eps=1e-15):
""" Returns the null-space of matrix A (as column-vectors) """
u, s, vT = np.linalg.svd(A, full_matrices=1, compute_uv=1)
r = sum(s > eps)
null_space = vT[r:,:]
return null_space.T
import numpy as np
import cv2
cap = cv2.VideoCapture(r'./input_file.mp4')
#OSX:
fourcc = cv2.cv.CV_FOURCC('m', 'p', '4', 'v')
vout = cv2.VideoWriter()
out_fps = 30.0
success = vout.open('output_file.mov',fourcc,out_fps,(720,1280),True)
from transformers import AutoModelWithLMHead, AutoTokenizer
import logging
model_name = 'gpt2-xl'
dev = 'cuda'
#dev = 'cpu'
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelWithLMHead.from_pretrained(model_name).to(dev)