Skip to content

Instantly share code, notes, and snippets.

View koaning's full-sized avatar

vincent d warmerdam koaning

View GitHub Profile
@koaning
koaning / experiment.py
Created January 16, 2020 21:19
demonstrates the diminishing dependence as features increase
import numpy as np
import matplotlib.pylab as plt
def run_with_samples(feats=1):
n = 1000
xs = np.random.uniform(0, 2, (n, feats))
ys = 1.5 + xs.sum(axis=1) + np.random.normal(0, 1, (n,))
size_subset = 500
n_samples = 2000
@koaning
koaning / biased-hard.csv
Last active November 29, 2019 11:32
feedback experiment
x y z
575.9169941454602 456.4364641163653 b
524.7679233463399 454.659622813655 b
536.1853203147283 414.6387874887763 b
554.7345847720682 392.6003138461853 b
558.7216445350003 455.7009797890023 b
512.1738453368777 407.6844578991705 b
494.68119055863497 379.00447835274645 b
521.4275424582694 409.29480593833387 b
504.69631038511756 417.3711528143935 b
@koaning
koaning / main.py
Created November 16, 2019 19:25
keras grid job
import uuid
import json
import random
import keras
import numpy as np
import tensorflow as tf
import click
async def fetch(url, json_body, session):
async with session.post(url, json=json_body) as response:
return await response.read()
async def run(json_bodies, n_sim=1000):
tasks = []
url = make_url(n_sim=n_sim)
# Fetch all responses within one Client session,
# keep connection alive for all requests.
async with ClientSession(connector=TCPConnector(limit=None), read_timeout=60000, conn_timeout=60000) as session:
@koaning
koaning / app.py
Created January 14, 2018 12:16
sushigo-chalice
import random
import math
from chalice import Chalice
app = Chalice(app_name='sushigo-algorithm')
app.debug = False
def sort_hand(hand, order):
card_dict = {card: i for i, card in enumerate(order)}
return sorted(hand, key=lambda x: card_dict[x])
@koaning
koaning / gpu-gradient.py
Last active April 26, 2017 20:32
same board but with gpu
import tensorflow as tf
import numpy as np
import os
import uuid
TENSORBOARD_PATH = "/tmp/tensorboard-switchpoint"
# tensorboard --logdir=/tmp/tensorboard-switchpoint
x1 = np.random.randn(35) - 1
x2 = np.random.randn(35) * 2 + 5
@koaning
koaning / gradient-board.py
Created April 22, 2017 15:04
tensorflow and tensorboard gradient search
import tensorflow as tf
import numpy as np
import os
import uuid
TENSORBOARD_PATH = "/tmp/tensorboard-switchpoint"
# tensorboard --logdir=/tmp/tensorboard-switchpoint
x1 = np.random.randn(35)-1
x2 = np.random.randn(35)*2 + 5
@koaning
koaning / app.py
Created March 24, 2017 18:42
flask super basic start
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
@koaning
koaning / latex
Created March 14, 2017 12:27
latex align
\begin{align*}
E[\pmb{Ax + y}] &= \pmb{A}(E[\pmb{x}]) + \pmb{y} \\
Cov[\pmb{Ax + y}] &= \pmb{A}(Cov[\pmb{x}])\pmb{A}^T
\end{align*}
@koaning
koaning / tf.py
Created March 9, 2017 16:13
tensorflow layer example
import tensorflow as tf
import numpy as np
import uuid
x = tf.placeholder(shape=[None, 3], dtype=tf.float32)
nn = tf.layers.dense(x, 3, activation=tf.nn.sigmoid)
nn = tf.layers.dense(nn, 5, activation=tf.nn.sigmoid)
encoded = tf.layers.dense(nn, 2, activation=tf.nn.sigmoid)
nn = tf.layers.dense(encoded, 5, activation=tf.nn.sigmoid)
nn = tf.layers.dense(nn, 3, activation=tf.nn.sigmoid)