Skip to content

Instantly share code, notes, and snippets.

@oiehot
oiehot / es6.js
Created April 23, 2017 04:29
ES6 Features
//
// ES6 Features
//
// 원본: http://es6-features.org
//
// 1. 상수
// =======
const PI = 3.141593
@oiehot
oiehot / pydl_backpropagation_layer2.py
Created April 9, 2017 00:43
오차역전파법을 위한 Relu층, Sigmoid층
import numpy as np
'''
class ReluLayer:
def __init__(self):
self.x = None
def forward(self, x):
self.x = x
if x > 0:
return x
@oiehot
oiehot / pydl_backpropagation_layer1.py
Created April 8, 2017 01:49
오차역전파법을 위한 덧셈층, 곱셈층
class AddLayer:
def __init__(self):
pass
def forward(self, x, y):
return x + y
def backward(self, dout):
dx = dout * 1
dy = dout * 1
return dx, dy
@oiehot
oiehot / pydl_mnist_train.py
Created March 18, 2017 04:14
mnist, 순전파, 2층 신경망 학습시키기
import sys, os
sys.path.append(os.pardir)
import numpy as np
from common.functions import *
from common.gradient import *
from dataset.mnist import load_mnist
class TwoLayerNet:
def __init__(self, inputSize, hiddenSize, outputSize, weight=0.01):
self.w1 = weight * np.random.randn(inputSize, hiddenSize)
@oiehot
oiehot / pydl_gradient_descent.py
Created March 11, 2017 05:02
머신러닝, 수치미분, 편미분, 기울기, 경사하강법
# 머신러닝, 수치 미분, 편미분, 기울기gradient, 경사 하강법gradient descent
# 수치 미분numerical differentiation, 전방 차분
def numerical_diff_bad(f, x):
h = 10e-50 # np.float32(1e-50) => 0.0, 반올림 오차 문제.
return (f(x+h) - f(x)) / h
# 수치 미분, 중심 차분
def numerical_diff(f, x):
h = 1e-4 # 0.0001
@oiehot
oiehot / maya_copyPivot.mel
Last active February 24, 2017 07:27
마야, 회전축 복사하기
global proc TZ_Transform_CopyPivot(string $src, string $dest) {
float $scalePivot[3];
float $rotatePivot[3];
$scalePivot = `xform -query -worldSpace -scalePivot $src`;
$rotatePivot = `xform -query -worldSpace -rotatePivot $src`;
xform -worldSpace -scalePivot $scalePivot[0] $scalePivot[1] $scalePivot[2] $dest;
xform -worldSpace -rotatePivot $rotatePivot[0] $rotatePivot[1] $rotatePivot[2] $dest;
}
@oiehot
oiehot / maya_subdiv.mel
Last active February 24, 2017 07:29
마야에서 Edge의 Normal, Crease, ArnoldSubdiv을 동시에 설정하기
// 0: Smooth
// 1: Jelly
// 2: Round Rect 1
// 3: Round Rect 2
// 4: Bevel
// 5: Hard
global proc TZ_Subdiv_SetLevel(int $level)
{
int $minSubdivLevel = max(5, $level); // 최저 Subdiv레벨: 5
@oiehot
oiehot / pydl_costfuncs.py
Last active February 19, 2017 04:07
평가함수, 평균제곱오차 & 교차엔트로피오차
import sys, os
import numpy as np
# 정답표, One hot label
t = np.array([
[0,0,1,0,0,0,0,0,0,0], # 2
[0,0,0,1,0,0,0,0,0,0], # 3
[0,0,0,0,0,1,0,0,0,0], # 5
[1,0,0,0,0,0,0,0,0,0], # 0
[0,1,0,0,0,0,0,0,0,0] # 1
@oiehot
oiehot / pydl_neuralnet_mnist.py
Last active February 19, 2017 04:08
MNIST, 이미 학습된 신경망을 사용해서 숫자 이미지를 추론하기
import sys, os
import numpy as np
import pickle
import random
from PIL import Image
# https://github.com/oreilly-japan/deep-learning-from-scratch/common, dataset
sys.path.append(os.pardir)
from dataset.mnist import load_mnist
from common.functions import sigmoid, softmax
@oiehot
oiehot / pydl_funcs.py
Last active February 18, 2017 02:53
딥 러닝 기초 함수들
import numpy as np
def step(x):
return np.array( x > 0, dtype=np.int )
def sigmoid(x):
y = 1 / (1 + np.exp(-x))
return y
def relu(x):