Skip to content

Instantly share code, notes, and snippets.

View jaymody's full-sized avatar
🙈
ignoring bugs

Jay Mody jaymody

🙈
ignoring bugs
View GitHub Profile
@jaymody
jaymody / docker_save_progress_bar.sh
Created June 2, 2020 23:43
docker save with a progress bar
# If you're impatient like me, a progress bar can be a comforting way to impulsively check the progress
# of your docker save command
#
# You'll need tqdm installed (https://github.com/tqdm/tqdm) for this to work.
docker save IMAGE_NAME | tqdm --bytes --total $(docker image inspect IMAGE_NAME --format='{{.Size}}') > OUTPUT_TAR_NAME
@jaymody
jaymody / main.c
Last active June 30, 2023 19:03
A demonstration of how CPU caches sensitive array accesses speed up your code.
/* Making matrix multiplication 10x faster by making it cache-aware.
$ gcc -O3 main.c && ./a.out
Slow: 4.142s
Fast: 0.482s
*/
#include <stdio.h>
#include <stdlib.h>
FROM tensorflow/tensorflow:1.13.2-py3
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update -y && apt upgrade -y && apt install git -y
RUN git clone https://github.com/openai/gpt-2 /gpt-2
WORKDIR /gpt-2
RUN python3 -m pip install --upgrade pip && python3 -m pip install -r requirements.txt
RUN python3 download_model.py 124M
@jaymody
jaymody / setup.sh
Last active January 11, 2023 10:44
Setting up https://github.com/jaymody/dotfiles in a ubuntu/debian machine.
# usage: curl -s https://gist.githubusercontent.com/jaymody/762417819fa017d75ff0870aa9ff0f2b/raw/setup.sh | sudo bash
# update and upgrade
apt update -y && apt upgrade -y
# packages
apt install -y \
ack \
coreutils \
curl \
@jaymody
jaymody / entropy_losses.ipynb
Last active December 11, 2022 18:39
Studying entropy based loss functions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jaymody
jaymody / losses.ipynb
Last active December 9, 2022 22:22
Quick notebook that shows that `nll_loss`, `cross_entropy`, and `kl_div` are equivalent loss functions for categorical data.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jaymody
jaymody / entropy.ipynb
Last active December 9, 2022 18:10
Playing around with entropy/information theory (equations from: https://machinelearningmastery.com/cross-entropy-for-machine-learning/)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jaymody
jaymody / Dockerfile
Last active October 31, 2022 17:07
ngc container with my dotfiles
FROM nvcr.io/nvidia/pytorch:22.09-py3
ENV DEBIAN_FRONTEND=noninteractive
# "essential" packages
RUN apt update -y && apt upgrade -y && apt install -y \
apt-transport-https \
build-essential \
ca-certificates \
coreutils \
@jaymody
jaymody / compute_embeddings.py
Created October 16, 2022 06:31
Quick cohere embeddings demo.
import json
import os
import cohere
import numpy as np
names = ["Vet", "Police", "Engineer"]
descriptions = [
"Vets are like doctors but for animals.",
"Police protect and serve the community.",
@jaymody
jaymody / main.py
Created October 5, 2022 03:15
Comparing jax code runtimes with jax.array vs np.array
import jax
import jax.numpy as jnp
def forward_fn(params, X):
for W, b in params[:-1]:
X = jax.nn.relu(X @ W + b)
final_W, final_b = params[-1]
return X @ final_W + final_b