การดึง kernel จากโครงข่ายประสาทเทียมที่ผ่านการเทรนแล้ว
วิธีหนึ่งในการตีความโมเดลคือการตรวจสอบคุณสมบัติของ kernel ใน convolutional layer ในแบบฝึกหัดนี้ จะดึง kernel หนึ่งตัวจาก convolutional neural network ที่มีน้ำหนักซึ่งบันทึกไว้ในไฟล์ hdf5
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การสร้างโมเดลภาพด้วย Keras
คำแนะนำการฝึกหัด
- โหลดน้ำหนักเข้าสู่โมเดลจากไฟล์
weights.hdf5 - ดึง convolutional layer แรกในโมเดลจากแอตทริบิวต์
layers - ใช้เมธอด
.get_weights()เพื่อดึงน้ำหนักออกจาก layer นี้
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Load the weights into the model
model.____('weights.hdf5')
# Get the first convolutional layer from the model
c1 = model.____[0]
# Get the weights of the first convolutional layer
weights1 = c1.____()
# Pull out the first channel of the first kernel in the first layer
kernel = weights1[0][...,0, 0]
print(kernel)