시작하기무료로 시작하기

모델 학습하기

이제 가장 재미있는 단계예요. 모델을 학습시켜 보겠습니다. 예측에 사용할 입력 특성 데이터는 NumPy 배열 predictors에, 예측 대상 데이터는 NumPy 배열 target에 들어 있어요. model은 미리 준비되어 있고, 이전 연습 문제의 코드로 이미 컴파일되어 있습니다.

이 연습은 강의의 일부입니다

Python으로 시작하는 Deep Learning

강의 보기

연습 안내

  • model을 학습하세요. 첫 번째 인수는 입력 특성(predictors), 두 번째 인수는 예측 대상 데이터(target)임을 기억하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# Import necessary modules
from tensorflow.keras.layers import Dense
from tensorflow.keras.models import Sequential

# Specify the model
n_cols = predictors.shape[1]
model = Sequential()
model.add(Dense(50, activation='relu', input_shape = (n_cols,)))
model.add(Dense(32, activation='relu'))
model.add(Dense(1))

# Compile the model
model.compile(optimizer='adam', loss='mean_squared_error')

# Fit the model
____
코드 편집 및 실행