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
;; Package for Range Maximum Query (RMQ) operations using Segment Trees. | |
;; Implemented in Racket v5.2.1. | |
;; Author: Viswanath Sivakumar <[email protected]> | |
;; Abstraction for integer ranges. | |
(define make-range | |
(lambda (low high) (cons low high))) | |
(define low | |
(lambda (range) (car range))) | |
(define high |
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
#include <event.h> | |
#include <evhttp.h> | |
#include <pthread.h> | |
#include <errno.h> | |
#include <string.h> | |
#include <fcntl.h> | |
#include <sys/socket.h> | |
#include <sys/types.h> | |
#include <netinet/in.h> | |
#include <iostream> |
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
#!/usr/bin/env python | |
import numpy | |
import theano | |
import time | |
def timer(func): | |
def wrapper(*args, **kwargs): | |
print("Executing func %s" % func.__name__) | |
start = time.time() |
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 gym | |
import random | |
import numpy as np | |
import tensorflow as tf | |
class DQN: | |
REPLAY_MEMORY_SIZE = 10000 | |
RANDOM_ACTION_PROB = 0.5 | |
RANDOM_ACTION_DECAY = 0.99 |
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 gym | |
import random | |
import numpy as np | |
import tensorflow as tf | |
class DQN: | |
REPLAY_MEMORY_SIZE = 10000 | |
RANDOM_ACTION_DECAY = 0.99 | |
MIN_RANDOM_ACTION_PROB = 0.1 |
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 gym | |
import random | |
import numpy as np | |
import tensorflow as tf | |
class DQN: | |
REPLAY_MEMORY_SIZE = 10000 | |
RANDOM_ACTION_DECAY = 0.99 | |
MIN_RANDOM_ACTION_PROB = 0.1 |
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 argparse | |
import tensorflow as tf | |
import time | |
def run(source_device, num_gpus=4): | |
shape = [100000000] | |
source_device = '/%s:0' % source_device | |
with tf.device(source_device): | |
weight_init = tf.truncated_normal_initializer() |
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 numpy as np | |
import gym | |
from gym.spaces import Discrete, Box | |
# ================================================================ | |
# Policies | |
# ================================================================ | |
class DeterministicDiscreteActionLinearPolicy(object): |
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 numpy as np, os | |
os.environ["THEANO_FLAGS"]="device=cpu,floatX=float64" | |
import theano, theano.tensor as T | |
import gym | |
def discount(x, gamma): | |
""" | |
Given vector x, computes a vector y such that | |
y[i] = x[i] + gamma * x[i+1] + gamma^2 x[i+2] + ... | |
""" |
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
class Trie: | |
def __init__(self, character, prob): | |
self.character = character | |
self.probability = prob | |
self.children = {} | |
def add_child(self, child): | |
assert self.character != '$', "Cannot add child to end token" | |
if child.character not in self.children: | |
self.children[child.character] = child |
OlderNewer