def build_model():
model = Sequential()
model.add(Dense(units = 4, activation = 'relu', input_shape = (8, )))
model.add(Dense(units = 20, activation = 'relu'))
model.add(Dense(units = 10, activation = 'relu'))
model.add(Dense(units = 1, activation = 'linear'))
# 옵티마이저의 learning rate를 설정하는 방법
model.compile(tf.keras.optimizers.RMSprop(learning_rate = 0.001), loss = 'mse', metrics = ['mse', 'mae'])
#model.compile('adam', 'mse')
return model
위 코드처럼 컴파일 할 때 라이브러리로 옵티마이저를 불러오고 하이퍼 파라미터 learning_rate에 값을 대입한다.
'인공지능 > 텐서플로우' 카테고리의 다른 글
EarlyStopping 라이브러리 사용법 (0) | 2022.06.13 |
---|---|
validation 데이터란 무엇이고 코드에서 사용하는 방법 (validation_split) (0) | 2022.06.13 |
tensorflow GridSearch를 이용한, 최적의 하이퍼 파라미터 찾기 (0) | 2022.06.10 |
tensorflow로 regression 문제 모델링 하는 방법 (0) | 2022.06.10 |
tensorflow로 분류의 문제 모델링 하는 법 (0) | 2022.06.10 |