Skip to content

Instantly share code, notes, and snippets.

View louiskirsch's full-sized avatar

Louis Kirsch louiskirsch

View GitHub Profile
@DougGregor
DougGregor / parallel_map.swift
Created December 24, 2020 01:10
Swift async/await implementation of a parallel map
extension Collection {
func parallelMap<T>(
parallelism requestedParallelism: Int? = nil,
_ transform: @escaping (Element) async throws -> T
) async throws -> [T] {
let defaultParallelism = 2
let parallelism = requestedParallelism ?? defaultParallelism
let n = self.count
if n == 0 {
@staceysv
staceysv / composite_histogram.json
Created August 24, 2020 23:46
Custom Vega spec for a composite histogram plot in wandb
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"padding": 5,
"signals": [
{
"name": "binOffset",
"value": 0
},
{
"name": "binStep",
@chychen
chychen / omniglot_tfreader.py
Last active May 24, 2021 13:07
load omniglot from tfds, then create tf.data.Dataset based on it.
import tensorflow as tf
import tensorflow_datasets as tfds
import numpy as np
import os
import matplotlib.pyplot as plt
from tensorflow.keras.utils import to_categorical
from absl import flags, logging
from tqdm.auto import tqdm
FLAGS = flags.FLAGS
@louiskirsch
louiskirsch / pbt-tf.py
Created June 7, 2018 06:24
population-based-training-tensorflow
import tensorflow as tf
import tensorflow.contrib as tfc
import numpy as np
import matplotlib.pyplot as plt
import observations
from functools import lru_cache
tf.reset_default_graph()
train_data, test_data = observations.cifar10('data/cifar',)
@Aaronmacaron
Aaronmacaron / install-alacritty-ubuntu.sh
Last active October 10, 2022 11:26
Install Alacritty on Ubuntu
#!/bin/bash
# This installs alacritty terminal on ubuntu (https://github.com/jwilm/alacritty)
# You have to have rust/cargo installed for this to work
# Install required tools
sudo apt-get install -y cmake libfreetype6-dev libfontconfig1-dev xclip
# Download, compile and install Alacritty
git clone https://github.com/jwilm/alacritty
@louiskirsch
louiskirsch / tf_ring_buffer.py
Created April 1, 2018 09:08
A tensorflow ring buffer implementation
class RingBuffer:
def __init__(self, scope_name, components, size):
"""
Create a new ring buffer of size `size`.
Each item in the ring buffer is a tuple of variables of size `len(components)`.
:param scope_name: A scope name for the newly created variables
:param components: Defines the type of items in the buffer. An iterable of tuples (name: str, shape: Iterable, dtype)
:param size: The maximum size of the buffer
@gyglim
gyglim / tensorboard_logging.py
Last active August 23, 2023 21:29
Logging to tensorboard without tensorflow operations. Uses manually generated summaries instead of summary ops
"""Simple example on how to log scalars and images to tensorboard without tensor ops.
License: BSD License 2.0
"""
__author__ = "Michael Gygli"
import tensorflow as tf
from StringIO import StringIO
import matplotlib.pyplot as plt
import numpy as np
@crittermike
crittermike / new_gist_file
Created August 15, 2016 13:43
View the git log for a specific line or number of lines in a file
git log -L 1,1:some-file.txt
@yrevar
yrevar / imagenet1000_clsidx_to_labels.txt
Last active May 4, 2025 13:55
text: imagenet 1000 class idx to human readable labels (Fox, E., & Guestrin, C. (n.d.). Coursera Machine Learning Specialization.)
{0: 'tench, Tinca tinca',
1: 'goldfish, Carassius auratus',
2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias',
3: 'tiger shark, Galeocerdo cuvieri',
4: 'hammerhead, hammerhead shark',
5: 'electric ray, crampfish, numbfish, torpedo',
6: 'stingray',
7: 'cock',
8: 'hen',
9: 'ostrich, Struthio camelus',
@kastnerkyle
kastnerkyle / example_theano_clone.py
Created July 29, 2014 14:26
Example of using theano.clone to replace an input
import theano.tensor as T
import theano
a = T.vector()
b = T.matrix()
fa = a ** 2
f = theano.function([a], fa)
f2 = theano.function([b], theano.clone(fa, replace={a: b}, strict=False))
print(f([2]))
print(f2([[2]]))