View strip_water.py
"""
Strip watermarks from some photos.
Expects a directory 'pairs' with watermarked and
unwatermarked photos. Watermarked photos have a _w suffix
in their filename. All names end with '.JPG'.
Expects another directory, 'remove_watermarks', with an
arbitrary set of photos. These photos are stripped of all
watermarks that were present in the training pairs.
View main.py
"""
Terminates on macOS but not Linux.
"""
import socket
from threading import Thread
import time
def main():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
View index.go
package main
import (
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"strconv"
"strings"
View imagenet.go
// Find miniImageNet images in the original dataset.
package main
import (
"fmt"
"image"
"image/jpeg"
"io"
"log"
View main.go
// Solves this problem: http://1mage.us/1339.
package main
import (
"fmt"
"math"
"math/rand"
"sort"
View main.go
// Solves this problem: http://1mage.us/1339.
package main
import (
"fmt"
"math"
"math/rand"
"sort"
View annoying.md

Intro

When using policy gradients (PG) with discrete actions, a softmax distribution is typically used to represent the output distribution. This document describes how the softmax+PG combination can be problematic, even with perfect sampling and a linear model.

Suboptimal asymptotes

Suppose we have a multi-armed bandit problem. We can define our agent as a

View huge_graph.py
"""
Generate some second-derivatives that make TF cry.
On my machine, this takes several minutes to run and uses
about 2GB of memory.
"""
import time
import tensorflow as tf
View main.py
from tensorflow.examples.tutorials.mnist import input_data
data = input_data.read_data_sets('MNIST_data', one_hot=True)
print(len(data.train.labels))
# prints 55000, not 60000 like you'd expect.
View softmax_deriv.py
import numpy as np
import tensorflow as tf
sess = tf.Session()
in_vec = tf.constant(np.array([1, 2, 3], dtype='float32'))
one_hot = tf.constant(np.array([0, 1, 0], dtype='float32'))
in_grad = tf.gradients(tf.nn.softmax_cross_entropy_with_logits(labels=one_hot, logits=in_vec), in_vec)[0]
print(sess.run(in_grad))
print(sess.run(tf.nn.softmax(in_vec) - one_hot))