Skip to content

Instantly share code, notes, and snippets.

@oiehot
oiehot / pydl_funcs.py
Last active Feb 18, 2017
딥 러닝 기초 함수들
View pydl_funcs.py
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):
View sketchup_exportFbx.rb
def exportFbx(filename)
if Sketchup.open_file(filename) then
model = Sketchup.active_model
dir = File.dirname(filename)
basename = File.basename(filename,'.*')
#model.save_thumbnail "#{dir}/#{basename}.png"
model.export "#{dir}/#{basename}.fbx", false
else
puts "Failed to Load fbx."
end
@oiehot
oiehot / pydl_costfuncs.py
Last active Feb 19, 2017
평가함수, 평균제곱오차 & 교차엔트로피오차
View pydl_costfuncs.py
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 Feb 19, 2017
MNIST, 이미 학습된 신경망을 사용해서 숫자 이미지를 추론하기
View pydl_neuralnet_mnist.py
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 / maya_copyPivot.mel
Last active Feb 24, 2017
마야, 회전축 복사하기
View maya_copyPivot.mel
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 Feb 24, 2017
마야에서 Edge의 Normal, Crease, ArnoldSubdiv을 동시에 설정하기
View maya_subdiv.mel
// 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_gradient_descent.py
Created Mar 11, 2017
머신러닝, 수치미분, 편미분, 기울기, 경사하강법
View pydl_gradient_descent.py
# 머신러닝, 수치 미분, 편미분, 기울기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 / pydl_mnist_train.py
Created Mar 18, 2017
mnist, 순전파, 2층 신경망 학습시키기
View pydl_mnist_train.py
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_backpropagation_layer1.py
Created Apr 8, 2017
오차역전파법을 위한 덧셈층, 곱셈층
View pydl_backpropagation_layer1.py
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_backpropagation_layer2.py
Created Apr 9, 2017
오차역전파법을 위한 Relu층, Sigmoid층
View pydl_backpropagation_layer2.py
import numpy as np
'''
class ReluLayer:
def __init__(self):
self.x = None
def forward(self, x):
self.x = x
if x > 0:
return x
You can’t perform that action at this time.