การ compile และ fit โมเดล

Introduction to Deep Learning in Python

Dan Becker

Data Scientist and contributor to Keras and TensorFlow libraries

ทำไมต้อง compile โมเดล

  • ระบุ optimizer
    • มีตัวเลือกหลายแบบและมีความซับซ้อนทางคณิตศาสตร์
    • "Adam" มักเป็นตัวเลือกที่ดี
  • ฟังก์ชัน loss
    • "mean_squared_error" นิยมใช้กับ regression
Introduction to Deep Learning in Python

การ compile โมเดล

n_cols = predictors.shape[1]
model = Sequential()
model.add(Dense(100, activation='relu', input_shape=(n_cols,)))
model.add(Dense(100, activation='relu'))
model.add(Dense(1))
model.compile(optimizer='adam', loss='mean_squared_error')
Introduction to Deep Learning in Python

การ fit โมเดลคืออะไร

  • ใช้ backpropagation และ gradient descent กับข้อมูลเพื่ออัปเดตค่า weights
  • การปรับสเกลข้อมูลก่อน fit ช่วยให้การ optimize ทำงานได้ดีขึ้น
Introduction to Deep Learning in Python

การ fit โมเดล

n_cols = predictors.shape[1]
model = Sequential()
model.add(Dense(100, activation='relu', input_shape=(n_cols,)))
model.add(Dense(100, activation='relu'))
model.add(Dense(1))
model.compile(optimizer='adam', loss='mean_squared_error')
model.fit(predictors, target)
Introduction to Deep Learning in Python

มาฝึกกันเถอะ!

Introduction to Deep Learning in Python

Preparing Video For Download...