Skip to content

Instantly share code, notes, and snippets.

View koaning's full-sized avatar

vincent d warmerdam koaning

View GitHub Profile
@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 / 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 / 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 / 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])
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 / 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
@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 / 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 / config-mega-basic.yml
Last active November 1, 2022 11:39
DIET Benchmarks
language: en
pipeline:
- name: WhitespaceTokenizer
- name: CountVectorsFeaturizer
- name: EmbeddingIntentClassifier
policies:
- name: EmbeddingPolicy
max_history: 10
epochs: 100
batch_size:
@koaning
koaning / index.html
Last active April 8, 2020 12:52
DIET architecture interactive demo
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://d3js.org/d3.v5.min.js"></script>
<div class="container" style="width=600px; margin: 0 auto;">
<h2>DIET Interactive Demo</h2>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="100%" viewBox="-0.5 -0.5 1832 1057">
<defs>
<linearGradient x1="0%" y1="0%" x2="0%" y2="100%" id="mx-gradient-fff2cc-1-ffd966-1-s-0">
<stop offset="0%" style="stop-color:#fff2cc"/>