Skip to content

Instantly share code, notes, and snippets.

a conversation about the einops lib and why it's hard to optimize ML:

<PapuaHardyNet> the solution is obviously jax acc to shawn

which is why i'm thinking to also build a jax equivalent and compare all three: pytorch, pytorch + einops, jax. Let's see if I have the bandwidth to do so

<nshepperd2> einops is really cool imo

diff --git a/src/ b/src/
index d9e2131..366c411 100755
--- a/src/
+++ b/src/
@@ -9,7 +9,7 @@ import tensorflow as tf
import model, sample, encoder
def sample_model(
- model_name='117M',
+ model_name='1558N',
Miladiouss /
Last active October 27, 2023 03:41
Create PyTorch datasets and dataset loaders for a subset of CIFAR10 classes.
import torchvision
import torchvision.transforms as transforms
from torchvision.datasets import CIFAR10
from import Dataset, DataLoader
import numpy as np
# Transformations
RC = transforms.RandomCrop(32, padding=4)
RHF = transforms.RandomHorizontalFlip()
RVF = transforms.RandomVerticalFlip()
fasiha /
Last active June 23, 2022 12:44
Short-time Fourier transform with inverse in Python/Numpy, see
import numpy as np
import numpy.fft as fft
def stft(x, Nwin, Nfft=None):
Short-time Fourier transform: convert a 1D vector to a 2D array
The short-time Fourier transform (STFT) breaks a long vector into disjoint
chunks (no overlap) and runs an FFT (Fast Fourier Transform) on each chunk.
kylemcdonald /
Created January 3, 2016 08:56
Minimal code for rendering a numpy array as an image in a Jupyter notebook in memory. Borrowed from the Deep Dream notebook.
import PIL.Image
from cStringIO import StringIO
import IPython.display
import numpy as np
def showarray(a, fmt='png'):
a = np.uint8(a)
f = StringIO()
PIL.Image.fromarray(a).save(f, fmt)
kamiller /
Created November 1, 2012 21:40
python rsync impl
## {{{ (r4)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
This is a pure Python implementation of the [rsync algorithm](TM96).
[TM96] Andrew Tridgell and Paul Mackerras. The rsync algorithm.
Technical Report TR-CS-96-05, Canberra 0200 ACT, Australia, 1996.