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 Database from 'better-sqlite3'; | |
import { createDatabaseClient } from './proxy.ts'; | |
// 1) Create an in-memory DB and your table(s). | |
const db = new Database(':memory:'); | |
db.exec(` | |
CREATE TABLE users ( | |
id TEXT PRIMARY KEY, | |
data JSON | |
); |
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
lambda image: blur(color_jitter(random_crop(image)) |
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
// ChatGPT is going to take my job | |
package main | |
import ( | |
"bufio" | |
"flag" | |
"fmt" | |
"os" | |
"regexp" | |
"sort" |
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
#! /bin/bash | |
set -euxo pipefail | |
job_file="cluster_jobs/${1}.py" | |
if [[ ! -f "${job_file}" ]]; then | |
echo "${job_file} not found" | |
exit 1 | |
fi | |
RAY_ADDRESS=${RAY_ADDRESS:-""} |
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 types import SimpleNamespace | |
import yahp as hp | |
import torch | |
from torch import nn | |
from torch.autograd import Function as Function | |
from einops import rearrange | |
from einops.layers.torch import Rearrange | |
# A one-file implementation of the reversible VIT architecture |
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
"""run.py:""" | |
#!/usr/bin/env python | |
import os | |
import torch | |
import torch.distributed as dist | |
import torch.multiprocessing as mp | |
def run(rank, size): | |
""" Distributed function to be implemented later. """ | |
pass |
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 | |
def single_matrix(): | |
x = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]) | |
I, J, K = x.shape | |
x_ein = np.einsum("ijk->ij", x) | |
x_loop = np.empty((I, J)) | |
for i in range(I): |
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 torch | |
import torch.nn as nn | |
from params import params | |
# NOTATION: | |
# W_k = W (k as subscript) | |
# Wk = W (k as superscript) | |
class MultiHeadAttention(nn.Module): |
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 React from "react"; | |
import { fromPairs } from "lodash-es"; | |
import clsx from "clsx"; | |
// This is my styled-components replacement | |
// Taken from: | |
// https://github.com/MathiasGilson/Tailwind-Styled-Component/blob/master/src/domElements.ts | |
const elementsArray: (keyof JSX.IntrinsicElements)[] = [ | |
"a", | |
"abbr", |
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
#! /usr/bin/python3 | |
import sys | |
import os.path | |
fpath = sys.argv[1] | |
assert os.path.isfile(fpath) | |
abs_path = os.path.abspath(fpath) | |
dirname = os.path.dirname(abs_path) | |
fname = os.path.basename(abs_path) |
NewerOlder