This file contains hidden or 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 DQN(object): | |
def __init__(self, input, num_actions): | |
self.conv1 = nn.Conv2d(input, 32, 3, stride=2, padding=1) | |
self.conv2 = nn.Conv2d(input, 32, 3, stride=2, padding=1) | |
self.conv3 = nn.Conv2d(input, 32, 3, stride=2, padding=1) | |
self.linear = nn.Linear(256, num_actions) | |
""" initialize weights""" | |
def forward(self, inputs): | |
x = nn.elu(self.conv1(inputs)) | |
x = nn.elu(self.conv2(x)) |
This file contains hidden or 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 subprocess | |
chapters = [ | |
'intro', | |
'linear_algebra', | |
'prob', | |
'numerical', | |
'ml', |
This file contains hidden or 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
for i in range(3): | |
with open('./txt-file-'+str(i)+'.txt', 'wb+') as f: | |
for x in {f.write, __import__('__builtin__').__dict__['print']}: | |
x(str([__import__('random').__dict__['choice'](map(chr,range(97, 123))) for n in range(10)])) | |
print __import__('random').__dict__['randint'](1, 43) * __import__('random').__dict__['randint'](1, 43) |
This file contains hidden or 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
def rolling_apply_slow(a, w): | |
print len(a) | |
"""applys a function to a window slowly b/c python loops != c loops""" | |
r = np.empty(a.shape) | |
r.fill(np.nan) | |
for i in range(w-1, a.shape[0]): | |
r[i] = max(a[(i-w+1):i+1]) | |
print len(r) | |
return r |
This file contains hidden or 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
``` | |
-----BEGIN PGP MESSAGE----- | |
Version: GnuPG v1 | |
owGbwMvMwMR4MoOlxuXq1RjG0wfeJTGERs0/X62UlJ9SqWRVrZSck5maVwJi5SXm | |
pipZKWWnViYlFqfqZeYr5OWnpOplFStA1egolaUWFWfm5wFVGeiZ61ko1eqAlIM0 | |
p2XmpacWFRRlgsxSMjNOTTI2TEtNMrNINTMxSjQxTTY3SrY0TbY0szAwMU82MUkx | |
TTE1TQYamZFfXIJiqxLYzPjMFKCoM0S9s4mJi6mLqakzUK4ULJFqlGJsYGZsnJqa | |
ZpyWmGSUmpiYbGmRmJyYapqaZGpgAFJYnFoE9VJeamJOalFiSVVOYloayNFAqbLM | |
5FQkX6dnlmSUJmHRBlJeUlkA4penJsVDdcYnZealAL2MHCaGQJXJJZkgrYYmxkYG |
This file contains hidden or 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 | |
def changeslow(coins, amounts, highest, sum_coins, goal, store): | |
if sum_coins == goal: | |
store == show(coins, amounts, store) | |
return | |
if sum_coins > goal: | |
return | |
for value in amounts: |
This file contains hidden or 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 | |
def answer(x): | |
len_x = len(x) | |
sum_x = sum(x) | |
if sum_x % len_x == 0: | |
return len_x | |
else: | |
return len_x - 1 |
This file contains hidden or 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 | |
def answer(x, y): | |
sum_x, sum_y = sum(x), sum(y) | |
before = max(x, y) | |
after = min(x, y) | |
if after == 0: | |
return 100 | |
return int(round(abs((sum(before) / sum(after) - 1)) * 100)) | |
This file contains hidden or 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 node | |
function name1(err) { | |
var name = ''; | |
var interation = 0; | |
for (var i = 0; i < 9007199254740992; ++i) { | |
delete global[name]; | |
name += 'x'; | |
global[name] = 42; | |
iteration = i; | |
//speed up the printing, console.log is a snail |
This file contains hidden or 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 bash | |
trap 'exit' ERR | |
set -u | |
DIR="$(pwd)" | |
LOG="$DIR/times/times.txt" | |
PROGRAMS=($(find $DIR -maxdepth 1 -type f | grep -v "$(basename $0)")) | |
mkdir -p $DIR/times | |
touch $LOG | |
read -a ITERATIONS <<< "1 5 10 50 100 500 1000 5000 10000 50000 100000" | |
echo "timing for each random array" |