$ git push
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin main
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.
⭐fatal: The current branch main has no upstream branch.
순차모델 사용, 신경망 계층을 순차적으로 더하여 순차 모델로 불리며 신경망을 구성하는 방법 중 가장 기본적인 방법
차후, 복잡한 모델을 구성할 때에는 함수형 모델*(Functional Model)을 사용할 수 있음
* 함수형 모델은 신경망 계층을 순차적으로 계산하지 않을 수 있음
➕ Functional Model
# 2. Model(Function)
from tensorflow.keras.models import Model
from tensorflow.keras.layers import Input
input1 = Input(shape=(13,)) # input_shape=(13,)
dense1 = Dense(50, activation='relu')(input1) # Hidden Layer
dense2 = Dense(40, activation='sigmoid')(dense1)
dense3 = Dense(30, activation='relu')(dense2)
dense4 = Dense(20, activation='linear')(dense3)
output1 = Dense(1, activation='linear')(dense4) # output=1
model = Model(inputs=input1, outputs=output1) # Model Construction 끝 부분에서 최종적으로 input과 out을 정리
# Sequential model과 달리 dense를 직접 입력할 수 있으므로 순차적으로 계산하지 않을 수 있음
# (Sequential에서 2번째 layer 층을 순서를 옮겨서 4번째 layer 층으로 만들 수 있음)
# Sequential model과 달리 dense를 skip 할 수 있음
model.add(Dense(1, input_dim=1))
모델에 Dense Layer를 순차적으로 추가
Dense layer는 인공신경망(Artifical Neuron Network)에서 사용되는 레이어로, 입력과 출력을 연결시켜주는 역할을 함
layer의 종류로는 Dense 외에도 Convolution, MaxPooling, Flatten 등이 있음
- Dense의 첫 번째 인자: 출력 뉴런수
- Dense의 두 번째 인자: 입력 뉴런수
model.compile(loss='mae', optimizer='adam')
구성한 모델을 실제로 생성
loss를 측정하는 방법으로는 mae(mininum absolute error) 사용
MAE explaination image
오차를 보정하는 방법으로는 adam 사용
model.fit(x, y, epochs=10)
모델을 훈련하는 과정
- fit의 첫 번째 인자: x_train_data
- fit의 두 번째 인자: y_train_data
- fit의 세번째 인자: epochs, 훈련 횟수
⚠️ 초기 weight가 랜덤값이므로 실행 시 마다 훈련 결과가 달라짐
⚠️epochs가 과하게 높을 경우, 과적합(Overfitting) 문제가 발생할 수 있으므로 유의
➕ fit(verbose)에 따른 출력 형태 타입
model.fit(x, y, epochs=10, verbose=0)
'''
Result
진행과정 나오지 않음
'''
model.fit(x, y, epochs=10, verbose=1)
'''
Result
Epoch 50/50
323/323 [==============================] - 0s 762us/step - loss: 45.8877 - val_loss: 38.3869
'''
model.fit(x, y, epochs=10, verbose=2)
'''
Result
Epoch 50/50
323/323 - 0s - loss: 43.5736 - val_loss: 33.5931 - 214ms/epoch - 664us/step
'''
model.fit(x, y, epochs=10, verbose=3)
'''
Result # verbose = 3 이상
Epoch 50/50
'''