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
from selenium import webdriver | |
import time | |
if __name__ == '__main__': | |
# start firefox | |
driver = webdriver.Firefox() | |
# load eye test | |
driver.get('http://wvw.igame.com/eye-test/') | |
# wait loading | |
time.sleep(3) |
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
def argmax1(array): | |
return array.index(max(array)) | |
def argmax2(array): | |
return max(range(len(array)), key=lambda x: array[x]) |
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
def replace_chars(text): | |
chars = ",.?!:;" | |
for c in chars: | |
if c in text: | |
text = text.replace(c, '') | |
return text |
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 | |
def batch_normalization(x, gamma, beta, eps=2e-5): | |
mean = x.mean(axis=0) | |
var = x.var(axis=0) | |
x_hat = (x - mean) / np.sqrt(var + eps) | |
return gamma * x_hat + beta | |
def layer_normalization(x, gamma, beta, eps=2e-5): | |
mean = x.mean(axis=1)[:, np.newaxis] |
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
ls -t * | xargs -I{} file {} | grep "PNG image data" | cut -d ":" -f 1 | parallel -j 8 convert "{}" -colorspace sRGB -type truecolor "target/{.}.jpg" |
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
$latex = 'platex'; | |
$bibtex = 'pbibtex'; | |
$dvipdf = 'dvipdfmx %O -o %D %S'; | |
$makeindex = 'mendex %O -o %D %S'; | |
$pdf_mode = 3; | |
$ENV{TZ} = 'Asia/Tokyo'; | |
$ENV{OPENTYPEFONTS} = '/usr/share/fonts//:'; | |
$ENV{TTFONTS} = '/usr/share/fonts//:'; |
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 heapq | |
INF = float('inf') | |
def dijkstra(graph, weights, s): | |
d = {v: INF for v in graph} | |
d[s] = 0 | |
pi = {s: None} | |
queue = [] | |
heapq.heappush(queue, (0, s)) |
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
INF = float('inf') | |
def dag_shortest_path(graph, weights, torder, s): | |
d = {v: INF for v in graph} | |
d[s] = 0 | |
pi = {s: None} | |
for u in torder: | |
for v in graph[u]: | |
d_temp = d[u] + weights[u, v] | |
if d_temp < d[v]: |
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
INF = float('inf') | |
def bellman_ford(graph, weights, s): | |
d = {v: INF for v in graph} | |
d[s] = 0 | |
pi = {s: None} | |
edges = [(u, v) for u, vs in graph.items() for v in vs] | |
for _ in range(len(graph) - 1): | |
for (u, v) in edges: | |
d_temp = d[u] + weights[u, v] |
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
from collections import deque | |
INF = float('inf') | |
def bfs(graph, s): | |
d = {v: INF for v in graph} | |
d[s] = 0 | |
pi = {s: None} | |
queue = deque([s]) | |
while queue: |
OlderNewer