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/generate_unconditional_samples.py b/src/generate_unconditional_samples.py
index d9e2131..366c411 100755
--- a/src/generate_unconditional_samples.py
+++ b/src/generate_unconditional_samples.py
@@ -9,7 +9,7 @@ import tensorflow as tf
import model, sample, encoder
def sample_model(
- model_name='117M',
+ model_name='1558N',
@Miladiouss
Miladiouss / Select_CIFAR10_Classes.py
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 torch.utils.data import Dataset, DataLoader
import numpy as np
# Transformations
RC = transforms.RandomCrop(32, padding=4)
RHF = transforms.RandomHorizontalFlip()
RVF = transforms.RandomVerticalFlip()
@fasiha
fasiha / stft.py
Last active June 23, 2022 12:44
Short-time Fourier transform with inverse in Python/Numpy, see https://stackoverflow.com/q/51655119/500207
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
kylemcdonald / showarray.py
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)
IPython.display.display(IPython.display.Image(data=f.getvalue()))
@kamiller
kamiller / rsync.py
Created November 1, 2012 21:40
python rsync impl
## {{{ http://code.activestate.com/recipes/577518/ (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.
http://samba.anu.edu.au/rsync/.