เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

เพิ่ม Padding ให้กับ CNN

Padding ช่วยให้ convolutional layer รักษาความละเอียดของ input เอาไว้ได้ โดยการเพิ่มค่าศูนย์รอบขอบของภาพ เพื่อให้ convolution kernel สามารถทับซ้อนกับพิกเซลที่อยู่บริเวณขอบภาพได้

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

การสร้างโมเดลภาพด้วย Keras

ดูคอร์ส

คำแนะนำการฝึกหัด

เพิ่ม layer Conv2D และเลือก padding ที่ทำให้ output มีขนาดเท่ากับ input

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# Initialize the model
model = Sequential()

# Add the convolutional layer
model.add(____(10, kernel_size=3, activation='relu', 
                 input_shape=(img_rows, img_cols, 1), 
                 ____))

# Feed into output layer
model.add(Flatten())
model.add(Dense(3, activation='softmax'))
แก้ไขและรันโค้ด