Python/Python 딥러닝

본 포스팅은 다음 포스팅으로부터 이어집니다 : keras를 이용한 mnist 데이터 분류(1) 모델 평가하기 evaluate = model.evaluate(x_test, y_test) print(evaluate) # [0.1212036104369623, 0.9739] [손실값, 정확도] 학습된 모델을 통해 값 예측하기 results = model.predict(x_test) print(results.shape) np.set_printoptions(precision=7) # numpy 소수점 제한(7자리) print(f'test[0]이 각 클래스에 속할 확률 : \n{results[0]}') arg_results = np.argmax(results, axis=-1) # 가장 큰 값의 인덱스를 가져온다. p..
본 포스팅은 다음 포스팅으로 이어집니다 : keras를 이용한 mnist 숫자 데이터 분류(2) 데이터 전처리(preprocessing) 스케일링 Normalization(MinMax) Robust Normalization 사분위값을 이용한다. 이상치의 영향을 덜 받는다. Standardization mean 차감을 통해 zero-centered화를 시켜주고 std로 나누어줌으로써 데이터가 일정 범위 안에 머무르게 한다. (x_train, y_train), (x_test, y_test) = load_data(path='mnist.npz') # 60,000개 10000개 # 학습 데이터 print(x_train.shape, y_train.shape) # (60000, 28, 28) (60000,) prin..
케라스에서 개발 과정 학습 데이터를 정의한다. 데이터에 적합한 모델을 정의한다. 손실함수, 옵티마이저, 평가지표를 선택하여 학습과정을 설정한다. 모델을 학습시킨다. 모델을 평가한다. 모델 구축 1. 모델 구성 model = Sequential() model.add(Dense(32, input_shape= (2, ), activation = 'relu' )) model.add(Dense(1, activation = 'sigmoid' )) 첫 번째 node에서는 input_shape를 전달해주어야 함. 활성화 함수activation function : 신경망의 뉴런(neuron)에서는 입력 신호의 가중치 합을 출력값으로 변환해 주는 함수 → 2. 컴파일 함수 호출 # 평균 제곱 오차 회귀 문제 model.c..
import numpy as np import matplotlib.pyplot as plt 확률적 경사하강법단점: 학습률(lr)을 학습하는 동안에 변경할 수 없다. → W : 파라미터(가중치, 편향) lr : 학습률(learning rate) dL/dW : 변화율class Sgd_ function:: init→ 학습률 learning_rate를 초기 입력받는다.class Sgd: """ SGD: Stochastic Gradient Descent W = W - lr * dL/dW """ def __init__(self, learning_rate=0.01): self.learning_rate = learning_rateclass Sgd_ function:: update파라미터 params와 변화율 gradi..
Codezoy
'Python/Python 딥러닝' 카테고리의 글 목록 (2 Page)