인공지능/딥러닝

딥러닝 : learning rate를 optimizer에 셋팅하기.

왕현성 2022. 12. 28. 15:45
728x90

이전에는 아래와같이 코드를 작성하였다.

model.compile(optimizer='Adam',loss='mse'

오차가 최소가 되는 점을 찾아야하는데, 아래 사진을 보면 너무 오래 걸릴 수도 있고, 지나칠 수도 있다

그래서 모델링을 하는 과정에 아래 코드와 같이 learning rate를 설정해 줄 수 있다.

def build_model():
  model = Sequential()
  model.add(Dense(units=64,activation='relu',input_shape=(9,)))
  model.add(Dense(units=64,activation='relu'))
  model.add(Dense(units=1,activation='linear'))
  model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=0.001),loss='mse',metrics=['mse','mae'])
  return model