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
ai = input('num 1: ') | |
bi = input('num 2: ') | |
ci = input('num 3: ') | |
inp = sorted([ai, bi, ci]) | |
operators = ['>', '==', '<'] | |
def exp_c(a, b, op): | |
return eval("{} {} {}".format(a, op, b)) |
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
# with for loop | |
# range() --> starts from 0 | |
def with_for_loop(): | |
for i in range(10): | |
print('Hit %d times' % (i+1)) | |
print('The tree fell down!!') | |
def with_while_loop(): | |
hit = 0 |
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 seq2dataset(seq, window_size): | |
dataset = [] | |
for i in range(len(seq)-window_size): | |
subset = seq[i:(i+window_size+1)] | |
dataset.append([code2idx[item] for item in subset]) | |
return np.array(dataset) |
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
code2idx = {'c4':0, 'd4':1, 'e4':2, 'f4':3, 'g4':4, 'a4':5, 'b4':6, | |
'c8':7, 'd8':8, 'e8':9, 'f8':10, 'g8':11, 'a8':12, 'b8':13} | |
idx2code = {0:'c4', 1:'d4', 2:'e4', 3:'f4', 4:'g4', 5:'a4', 6:'b4', | |
7:'c8', 8:'d8', 9:'e8', 10:'f8', 11:'g8', 12:'a8', 13:'b8'} | |
# Or use dict comprehension | |
idx2code = {v: k for k, v in code2idx.items()} |
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
# Whole data | |
seq = ['g8', 'e8', 'e4', 'f8', 'd8', 'd4', 'c8', 'd8', 'e8', 'f8', 'g8', 'g8', 'g4', | |
'g8', 'e8', 'e8', 'e8', 'f8', 'd8', 'd4', 'c8', 'e8', 'g8', 'g8', 'e8', 'e8', 'e4', | |
'd8', 'd8', 'd8', 'd8', 'd8', 'e8', 'f4', 'e8', 'e8', 'e8', 'e8', 'e8', 'f8', 'g4', | |
'g8', 'e8', 'e4', 'f8', 'd8', 'd4', 'c8', 'e8', 'g8', 'g8', 'e8', 'e8', 'e4'] |
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
http://tykimos.github.io/warehouse/2017-3-8_CNN_Getting_Started_handwriting_shape.zip |
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
6 | 148 | 72 | 35 | 0 | 33.6 | 0.627 | 50 | 1 | |
---|---|---|---|---|---|---|---|---|---|
1 | 85 | 66 | 29 | 0 | 26.6 | 0.351 | 31 | 0 | |
8 | 183 | 64 | 0 | 0 | 23.3 | 0.672 | 32 | 1 | |
1 | 89 | 66 | 23 | 94 | 28.1 | 0.167 | 21 | 0 | |
0 | 137 | 40 | 35 | 168 | 43.1 | 2.288 | 33 | 1 | |
5 | 116 | 74 | 0 | 0 | 25.6 | 0.201 | 30 | 0 | |
3 | 78 | 50 | 32 | 88 | 31.0 | 0.248 | 26 | 1 | |
10 | 115 | 0 | 0 | 0 | 35.3 | 0.134 | 29 | 0 | |
2 | 197 | 70 | 45 | 543 | 30.5 | 0.158 | 53 | 1 | |
8 | 125 | 96 | 0 | 0 | 0.0 | 0.232 | 54 | 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
from keras.utils import np_utils | |
from keras.datasets import mnist | |
from keras.models import Sequential | |
from keras.layers import Dense, Activation | |
(x_train, y_train), (x_test, y_test) = mnist.load_data() | |
x_train = x_train.reshape(x_train.shape[0], 784).astype('float32') / 255.0 | |
x_test = x_test.reshape(x_test.shape[0], 784).astype('float32') / 255.0 | |
y_train = np_utils.to_categorical(y_train) | |
y_test = np_utils.to_categorical(y_test) |
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
""" | |
1. main 함수에서 `async def A`를 호출 후 await 하고, 반환값을 받아 다시 `async def B`를 호출하는 방식 | |
""" | |
import asyncio | |
from socket import socket, AF_INET, SOCK_STREAM |
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 json | |
import pandas as pd | |
from collections import defaultdict | |
multi_depth_defaultdict = lambda: defaultdict(multi_depth_defaultdict) | |
df = pd.read_excel('category.xlsx') | |
data = multi_depth_defaultdict() |
NewerOlder