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
#!/bin/bash | |
# download and unzip dataset | |
#wget http://cs231n.stanford.edu/tiny-imagenet-200.zip | |
unzip tiny-imagenet-200.zip | |
current="$(pwd)/tiny-imagenet-200" | |
# training data | |
cd $current/train |
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 ubuntu:latest | |
RUN apt-get update | |
RUN apt-get install -y mecab libmecab-dev mecab-ipadic-utf8 |
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 functools import singledispatch | |
import numpy as np | |
@singledispatch | |
def test_function(arg): | |
print("default") | |
@test_function.register(int) | |
def _(arg): | |
print(f"arg is integer {arg}") |
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
\begin{tikzpicture}[->,>=stealth,shorten >=1pt,auto,node distance=2cm, | |
semithick, | |
val/.style={circle,fill=cyan,opacity=.6}] | |
\node[val] (a) {$1$}; | |
\node[right=0.1cm of a] (a1) {$u_{1}$}; | |
\node[above=0.1cm of a] (b) {$l$}; | |
\node[below=0.3cm of a] (c) {$\vdots$}; | |
\node[val, below=0.3cm of c] (d) {$i$}; | |
\node[below=0.3cm of d] (d2) {$\vdots$}; | |
\node[right=0.1cm of d] (d1) {$u_{i}$}; |
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 matplotlib | |
import os | |
# style setting | |
matplotlib.style.use('seaborn-white') | |
# font setting | |
fp = matplotlib.font_manager.FontProperties(fname=os.path.expanduser('~/Library/Fonts/ipaexg.ttf')) | |
plt.rcParams['font.family'] = fp.get_name() | |
plt.plot(0, 1) |
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 timeit | |
import functools | |
@functools.lru_cache(maxsize=None) | |
def fib(x): | |
if x < 2: | |
return x | |
return fib(x-1) + fib(x-2) | |
print(timeit.timeit('fib(100)', setup="from __main__ import fib")) |
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 html.parser import HTMLParser | |
import urllib.request | |
import re | |
def download(url, path): | |
with urllib.request.urlopen(url) as file: | |
file_name = path + "/" + url.split("/")[-1] | |
with open(file_name, 'wb') as local: | |
local.write(file.read()) |
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 tweepy | |
import time | |
api = tweepy.API(auth) | |
with open("log.txt", 'w') as f: | |
for i in range(1,100): | |
users_tweets = api.user_timeline(id=user,page=i,include_entities=True,count=100) | |
for tweet in users_tweets: | |
f.write(tweet.entities['urls'][0]["expanded_url"] + "\n") | |
time.sleep(30) |
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 os | |
import shutil | |
import random | |
src_name = 'train/' | |
drc_name = 'val/' | |
src_dir = os.listdir(src_name)[1:] | |
for sub_src_dir in src_dir: | |
os.mkdir(drc_name+sub_src_dir) |
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 pandas as pd | |
csv = pd.read_csv(file_name) | |
# csv | |
# "0", "1" | |
# Tom, 2 | |
# John, 3 | |
#... | |
csv["2"] = np.zeros(len(csv)) | |
for i in range(len(csv)): |