View encoder-decoder.py
# coding: utf-8
"""
Seq2Seq (Encoder-Decoder) Model
this model is the basic encoder decoder model without attention mechanism.
author: Keon Kim
"""
import numpy as np
import torch as th
import torch.nn as nn
View topsort.cpp
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <stack>
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
View dqn.py
# -*- coding: utf-8 -*-
import random
import gym
import numpy as np
from collections import deque
from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import RMSprop
EPISODES = 5000
View FenwickTree.cpp
class Fenwick{
private:
const int maxN = 10000;
public:
int table[maxN];
int sumQuery(int a, int b){
return sumQuery(b) - sumQuery(a-1);
}
View README.md

Used dueling network architecture with Q-learning, as outlined in this paper:

Dueling Network Architectures for Deep Reinforcement Learning
Ziyu Wang, Tom Schaul, Matteo Hessel, Hado van Hasselt, Marc Lanctot, Nando de Freitas
http://arxiv.org/abs/1511.06581

Command line:

python duel.py CartPole-v0 --gamma 0.995
View setup tensorflow on aws
#!/bin/bash
# stop on error
set -e
############################################
# install the required packages
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get -y install linux-headers-$(uname -r) linux-image-extra-`uname -r`
# install cuda
View spynet.py
# coding: utf-8
# Imports
import os
import cPickle
import numpy as np
import theano
import theano.tensor as T
View class + object + friend
#include <iostream>
using namespace std;
template <typename ObjectType>
class BaseClass{
public:
friend ObjectType;
int Increment(){
return obj.Increment();
View example.cpp
// Load Data and Labels in double types
data::Load(inputFile, data, true);
data::Load(inputLabel, labels, true);
arma::rowvec labels_row = labels.row(0); // extract first row
// Split Data
const auto value = data::TrainTestSplit(data, labels_row, testRatio);
Log::Info << "Train Data Count: " << get<0>(value).n_cols << endl;
Log::Info << "Test Data Count: " << get<1>(value).n_cols << endl;
View gist:38cc1ad13a7bd165a1788d9fe5b4ac36
keon@ubuntu:~/Downloads/kernels$ wget http://archive.ubuntu.com/ubuntu/pool/main/l/linux/linux-{image,image-extra,headers}-4.4.0-17-generic_4.4.0-17.33_amd64.deb--2016-04-02 23:50:35-- http://archive.ubuntu.com/ubuntu/pool/main/l/linux/linux-image-4.4.0-17-generic_4.4.0-17.33_amd64.deb
Resolving archive.ubuntu.com (archive.ubuntu.com)... 91.189.88.153, 91.189.91.15, 91.189.91.13, ...
Connecting to archive.ubuntu.com (archive.ubuntu.com)|91.189.88.153|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 18566294 (18M) [application/x-debian-package]
Saving to: ‘linux-image-4.4.0-17-generic_4.4.0-17.33_amd64.deb’
100%[============================================================>] 18,566,294 1.56MB/s in 13s
2016-04-02 23:50:48 (1.38 MB/s) - ‘linux-image-4.4.0-17-generic_4.4.0-17.33_amd64.deb’ saved [18566294/18566294]