Skip to content

Instantly share code, notes, and snippets.

View louiskirsch's full-sized avatar

Louis Kirsch louiskirsch

View GitHub Profile
@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',)
@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
@louiskirsch
louiskirsch / txt-to-slides.sh
Last active December 12, 2020 17:05
Convert dynalist exported plain text with spaces to remark presentation
#!/bin/bash
name=${1:-slides}
replace='s/^([^ ].*)/# \1§/g; s/^ {8}([^ ].*)/§### \1§/g; s/^ {4}([^ ].*)/§## \1§/g; s/ +(\![[])/\1/g; s/ {12}([^ ]+)/- \1/g; s/\![(]([0-9-]+)[)]/\1/g'
sed -E "$replace" <&0 | tr "§" "\n" > $name.md
markdown-to-slides -d $name.md -o $name.html
open $name.html
fig, ax = plt.subplots()
ax.set_title('Figure 2 - Progressing samples')
ax.set_xlabel('Erruption length')
ax.set_ylabel('Time since last erruption')
ax.set_xlim((np.min(x[:, 0]), np.max(x[:, 0])))
ax.set_ylim((np.min(x[:, 1]), np.max(x[:, 1])))
line, = ax.plot([], [])
def init():
line.set_data([], [])
@louiskirsch
louiskirsch / liveplot.py
Created March 7, 2017 08:13
Matplotlib live plot
import matplotlib.pyplot as plt
import numpy as np
import time
plt.rcParams['toolbar'] = 'None'
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
def draw():