Skip to content

Instantly share code, notes, and snippets.

View eridgd's full-sized avatar

Evan Davis eridgd

View GitHub Profile
import torch
import torch.nn as nn
lin = nn.Linear(9, 1, bias=False)
lin.weight.data = torch.ones_like(lin.weight)
x = torch.randn(1,1,3,3)
print(lin(x.flatten()))
# tensor([-1.7673], grad_fn=<SqueezeBackward3>)
@eridgd
eridgd / helloworld.js
Created April 1, 2018 18:57 — forked from max-mapper/helloworld.js
droneduino
var serialport = require('node-serialport')
var sp = new serialport.SerialPort("/dev/ttyO3", {
parser: serialport.parsers.raw,
baud: 9600
})
sp.on('data', function(chunk) {
console.log(chunk.toString('hex'), chunk.toString(), chunk)
})
@eridgd
eridgd / cem.md
Created March 1, 2018 23:15 — forked from kashif/cem.md
Cross Entropy Method

Cross Entropy Method

How do we solve for the policy optimization problem which is to maximize the total reward given some parametrized policy?

Discounted future reward

To begin with, for an episode the total reward is the sum of all the rewards. If our environment is stochastic, we can never be sure if we will get the same rewards the next time we perform the same actions. Thus the more we go into the future the more the total future reward may diverge. So for that reason it is common to use the discounted future reward where the parameter discount is called the discount factor and is between 0 and 1.

A good strategy for an agent would be to always choose an action that maximizes the (discounted) future reward. In other words we want to maximize the expected reward per episode.

@eridgd
eridgd / depth_to_space_viz.py
Created January 14, 2018 21:43 — forked from poolio/depth_to_space_viz.py
Subpixel convolution is tf.depth_to_space
def _phase_shift(I, r):
bsize, a, b, c = I.get_shape().as_list()
X = tf.reshape(I, (bsize, a, b, r, r))
X = tf.transpose(X, (0, 1, 2, 4, 3)) # bsize, a, b, 1, 1
X = tf.split(1, a, X) # a, [bsize, b, r, r]
X = tf.concat(2, [tf.squeeze(x, [1]) for x in X]) # bsize, b, a*r, r
X = tf.split(1, b, X) # b, [bsize, a*r, r]
X = tf.concat(2, [tf.squeeze(x, [1]) for x in X]) # bsize, a*r, b*r
return tf.reshape(X, (bsize, a*r, b*r, 1))
@eridgd
eridgd / depth_to_space_viz.py
Created January 14, 2018 21:43 — forked from poolio/depth_to_space_viz.py
Subpixel convolution is tf.depth_to_space
def _phase_shift(I, r):
bsize, a, b, c = I.get_shape().as_list()
X = tf.reshape(I, (bsize, a, b, r, r))
X = tf.transpose(X, (0, 1, 2, 4, 3)) # bsize, a, b, 1, 1
X = tf.split(1, a, X) # a, [bsize, b, r, r]
X = tf.concat(2, [tf.squeeze(x, [1]) for x in X]) # bsize, b, a*r, r
X = tf.split(1, b, X) # b, [bsize, a*r, r]
X = tf.concat(2, [tf.squeeze(x, [1]) for x in X]) # bsize, a*r, b*r
return tf.reshape(X, (bsize, a*r, b*r, 1))
@eridgd
eridgd / depth_to_space_viz.py
Created January 14, 2018 21:43 — forked from poolio/depth_to_space_viz.py
Subpixel convolution is tf.depth_to_space
def _phase_shift(I, r):
bsize, a, b, c = I.get_shape().as_list()
X = tf.reshape(I, (bsize, a, b, r, r))
X = tf.transpose(X, (0, 1, 2, 4, 3)) # bsize, a, b, 1, 1
X = tf.split(1, a, X) # a, [bsize, b, r, r]
X = tf.concat(2, [tf.squeeze(x, [1]) for x in X]) # bsize, b, a*r, r
X = tf.split(1, b, X) # b, [bsize, a*r, r]
X = tf.concat(2, [tf.squeeze(x, [1]) for x in X]) # bsize, a*r, b*r
return tf.reshape(X, (bsize, a*r, b*r, 1))
@eridgd
eridgd / data.csv
Created December 22, 2012 18:20
Whisky Reviews
name region rating numReviews price
1792 Ridgemont Reserve Bourbon 84 1 25
Aberfeldy 12 Highland 73.5 4 42.6666666667
Aberfeldy 1998 Signatory Vintage Highland 74 2 40
Aberlour 10 Speyside 81.5 6 46
Aberlour 10 Speyside 73 1 25
Aberlour 11 Duncan Taylor NC2 Speyside 87.25 4 60
Aberlour 12 Double Cask Matured Speyside 85.4285714286 14 38.3333333333
Aberlour 12 Non Chill Filtered Speyside 93.375 8 56.5
Aberlour 16 Speyside 88.75 4 54.3333333333
@eridgd
eridgd / index.html
Created December 17, 2012 14:58
Whisk(e)y Reviews by Rating and Price
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" width="device-width" content="target-densitydpi=device-dpi" />
<title>Whisk(e)y Reviews by Rating and Price</title>
<style>
body {
font: 10px sans-serif;
}
.axis path, .axis line {
fill: none;
@eridgd
eridgd / index.html
Created December 16, 2012 00:07
Whiskey Reviews
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path, .axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
@eridgd
eridgd / index.html
Created December 16, 2012 00:03
Whiskey Reviews
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path, .axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;