This file contains 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 tqdm import tqdm | |
import matplotlib.pyplot as plt | |
res = [] | |
N = 1000 | |
Bs = np.ceil(np.logspace(1, 6, 24)).astype(np.int32) | |
for B in tqdm(Bs): |
This file contains 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 PIL import Image | |
import sys | |
from random import shuffle | |
import os | |
imgs = [x.strip() for x in open(sys.argv[1])] | |
r, c = int(sys.argv[2]), int(sys.argv[3]) | |
w, h = Image.open(imgs[0]).size |
This file contains 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
#include <iostream> | |
#include <string> | |
class Cat { | |
public: | |
std::string s; | |
Cat (const std::string &s) : s(s) {} | |
Cat (const Cat &other) { |
This file contains 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
def hog(mag, angle, bin_dist=20): | |
h, w = mag.shape | |
bins = defaultdict(lambda: 0) | |
locs1 = (np.floor(angle / bin_dist) * bin_dist).astype(int) | |
locs2 = locs1 + bin_dist | |
ihs = (angle - locs1) / bin_dist | |
ils = 1 - ihs |
This file contains 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 cv2 | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
from mpl_toolkits.mplot3d import Axes3D | |
from matplotlib import cm, colors | |
# img = rgb ... | |
pixel_colors = img.reshape(-1, 3) | |
norm = colors.Normalize(vmin=-1.,vmax=1.) | |
norm.autoscale(pixel_colors) |
This file contains 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 pl | |
import seaborn as sns | |
import matplotlib | |
from matplotlib import pyplot as plt | |
from IPython import display | |
%matplotlib inline | |
%config InlineBackend.figure_format = 'retina' | |
sns.set() | |
# or |
This file contains 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
## IMPORTING | |
# add top-dirs to path | |
BASE_PATH = Path(__file__).resolve().parents[1] | |
sys.path[:0] = [str(BASE_PATH / 'src'), str(BASE_PATH)] | |
## LOGGING | |
def setup_logger(name, level, path=None): | |
if path is None: |
This file contains 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 sys | |
import time | |
import logging | |
import multiprocessing as mp | |
def work(x): | |
ys = [] | |
if x % 2 == 0: |
This file contains 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 torch as T | |
def maximal_marginal_relevance( | |
score_di_q: T.Tensor, | |
score_di_dj: T.Tensor, | |
*, | |
lam: float, | |
num_iters: int, |
This file contains 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
// adapted from | |
// https://wiki.haskell.org/Haskell_Quiz/FizzBuzz/Solution_Acontorer | |
#include <bits/stdc++.h> | |
#include <iostream> | |
using namespace std; | |
const vector<pair<int, string>> tags = { { 3, "Fizz" }, | |
{ 5, "Buzz" }, |
OlderNewer