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 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) |
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 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) |
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 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 |
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
## 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 |
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 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) |