Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64" | |
export CUDA_HOME=/usr/local/cuda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
StyledPad.propTypes = { | |
state: PropTypes.oneOf(['idle', 'playing', 'selected']).isRequired, | |
onClick: PropTypes.func.isRequired, | |
width: PropTypes.string, | |
height: PropTypes.string, | |
timing: PropTypes.string, | |
} | |
StyledSquare.defaultProps = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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() |
OlderNewer