Skip to content

Instantly share code, notes, and snippets.

View DavidSanwald's full-sized avatar

David Sanwald DavidSanwald

View GitHub Profile
@DavidSanwald
DavidSanwald / Reinforcement Learning.ipynb
Last active October 24, 2016 10:58
Not finished but I need some help/input (:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@DavidSanwald
DavidSanwald / memory.py
Created November 18, 2016 12:37
DQN with experience replay and target network
from collections import deque
from random import sample
class ReplayMemory:
def __init__(self, capacity):
self.samples = deque([], maxlen=capacity)
def store(self, exp):
self.samples.append(exp)
@DavidSanwald
DavidSanwald / ddqn.py
Last active December 14, 2016 19:31
Condensed one file gist for more convenient evaluation at https://gym.openai.com/evaluations/eval_GFtDBmuyRjCzcAkBibwYWQ
"""
Example implementation of Double DQN to provide an understandable, clear
implementation of the underlying algorithm using OpenAI gym as benchmark.
Further explanations:
https://davidsanwald.github.io/2016/12/11/Double-DQN-interfacing-OpenAi-Gym.html
If you need any help or have any questions, just drop me a note (:
The code is ased on the work of van Hasselt et al. esp. the Double DQN paper:
@DavidSanwald
DavidSanwald / .bashrc
Last active January 22, 2017 20:34
CUDA Blog
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda
import styled, { css } from 'styled-components'
import React from 'react'
import sample from 'lodash.sample'
import { darken } from 'polished'
import PropTypes from 'prop-types'
import { background } from '../config/styles'
const StyledPad = (props) => (
<StyledSquare {...props}
@DavidSanwald
DavidSanwald / loopFactory.js
Last active April 28, 2017 17:33
Klang Blocks
const loop = new Tone.Sequence(
function (time, col) {
const selectedPads = store.selectedPads
const playingPads = selectedPads.filter(
pad => pad.n === col
)
playingPads.forEach(pad => instrument.start(pad.m, time, 0, '1', 0))
}, [ 0, 1, 2, 3, 4, 5, 6, 7 ], '8n')
@DavidSanwald
DavidSanwald / props.js
Created April 28, 2017 17:08
StyledPadProps
StyledPad.propTypes = {
state: PropTypes.oneOf(['idle', 'playing', 'selected']).isRequired,
onClick: PropTypes.func.isRequired,
width: PropTypes.string,
height: PropTypes.string,
timing: PropTypes.string,
}
StyledSquare.defaultProps = {
@DavidSanwald
DavidSanwald / config.js
Created May 3, 2017 13:30
storybook config
import { configure, setAddon, addDecorator } from '@kadira/storybook';
import infoAddon from '@kadira/react-storybook-addon-info';
import centered from '@kadira/react-storybook-decorator-centered';
import {withKnobs} from '@kadira/storybook-addon-knobs';
setAddon(infoAddon);
addDecorator(withKnobs);
addDecorator(centered);
@DavidSanwald
DavidSanwald / debug.js
Last active September 26, 2018 13:46
Prototyping D3 charts inside React
const peek = ({ color = 'red', text = 'logged value:', weight = 'bold' } = {}) => x => {
const logContent = `%c ${text} ${x}`
const style = `color: ${color}; font-weight: ${weight};`
console.log(logContent, style)
return x
}
const peekGreen = peek({color: 'green'})
@DavidSanwald
DavidSanwald / data-join.js
Created September 26, 2018 12:06
saving individual parts of data join
// create single idempotent container that is appended to the DOM only once
const container = selection.selectAll('.lines').data([null]).enter().append('g').attr('class', 'lines')
// bind data, create and save the update selection
let update = container.selectAll('.line')
.data(data, d => d.id)
// create and save the exit selection
let exit = update.exit()