Deep Learning_2

YJ·2023년 6월 26일
0

▷ 오늘 학습 계획: 딥러닝 강의(4~6)

📖 02_Deep Learning from scratch

활성화 함수의 종류

  • Sigmoid(0과 1 사이)
  • Hyperbolic Tangent(-1과 1 사이)
  • ReLU
  • Leaky ReLU
  • Maxout
  • ELU

딥러닝 모델의 큰 규모

  • 기본 모델
  • 너비 스케일링: 노드의 숫자↑
  • 깊이 스케일링: layer 숫자↑
  • 해상도 스케일링: channel 숫자↑
  • 컴파운딩 스케일링: 너비 & 깊이 & 해상도

딥러닝 학습의 간단한 절차

출력값과 학습 데이터의 오차로 델타 함수를 만들어서 가중치 변경

오차의 역전파

Backpropagation

  • 출력층의 오차 계산
  • 출력층 가까이에 있는 은닉층의 가중치와 델타 계산
  • 다시 그 전 은닉층으로 계산

loss 함수

  • 회귀: MSE
  • 분류: cross entropy
    cross entropy의 델타는 오차와 같다.

📖 03_Mask man classification

from tensorflow.keras import Sequential, layers, models
from sklearn.metrics import classification_report, confusion_matrix

model = models.Sequential([

	# Convolutional은 보통 strides(1,1)
    # kernel_size (5,5), (3,3) 많이 사용함
    layers.Conv2D(32, kernel_size=(5,5), strides=(1,1), padding='same', 
    				activation='relu', input_shape=(150,150,1)),
    
    layers.MaxPooling2D(pool_size=(2,2), strides=(2,2)),
    # 보통 pool size랑 동일하게 strides
                        
    layers.Conv2D(64, (2,2), activation='relu', padding='same'),
    # 채널을 늘려서 더 많은 특성 관찰
                    
    layers.MaxPooling2D(pool_size=(2,2)),

    layers.Dropout(0.25),
    layers.Flatten(),
    layers.Dense(1000, activation='relu'),
    layers.Dense(1, activation='sigmoid'), # 마지막 출력값에 대한 설정
])

model.compile(
    optimizer='adam', loss=tf.keras.losses.BinaryCrossentropy(),
    metrics=['accuracy']
)

X_train = X_train.reshape(len(X_train), X_train.shape[1], X_train.shape[2], 1)
# X_train = X_train.reshape(-1, 150, 150, 1)

X_val = X_val.reshape(len(X_val), X_val.shape[1], X_val.shape[2], 1)
# X_val = X_val.reshape(-1, 150, 150, 1)

history = model.fit(X_train, y_train, epochs=4, batch_size=32)

model.evaluate(X_val, y_val)
model.predict(X_val)

prediction = (model.predict(X_val) > 0.5).astype('int32')
print(classification_report(y_val, prediction))
print(confusion_matrix(y_val, prediction))

▷ 내일 학습 계획: 딥러닝 강의(7~10)

[이 글은 제로베이스 데이터 취업 스쿨의 강의 자료 일부를 발췌하여 작성되었습니다.]

0개의 댓글