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

เซลล์ GRU ดีกว่า SimpleRNN

ในแบบฝึกหัดนี้ จะรันโมเดลเดิมจากบทแรกของคอร์สอีกครั้ง เพื่อเปรียบเทียบความแม่นยำของโมเดลโดยเปลี่ยนเซลล์จาก SimpleRNN เป็น GRU เพียงอย่างเดียว

โมเดลถูกเทรนมาแล้ว 10 epochs เช่นเดียวกับโมเดลก่อนหน้าที่ใช้เซลล์ SimpleRNN เพื่อให้เปรียบเทียบโมเดลได้ ชุดข้อมูลทดสอบ (x_test, y_test) และโมเดลเดิม SimpleRNN_model ถูกโหลดไว้ในสภาพแวดล้อมแล้ว

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

Recurrent Neural Networks (RNNs) สำหรับ Language Modeling ด้วย Keras

ดูคอร์ส

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

  • Import เซลล์ GRU
  • แสดง summary ของแต่ละโมเดล
  • แสดงความแม่นยำของแต่ละโมเดล

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

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

# Import the modules
from tensorflow.keras.layers import ____, Dense

# Print the old and new model summaries
SimpleRNN_model.____
gru_model.____

# Evaluate the models' performance (ignore the loss value)
_, acc_simpleRNN = SimpleRNN_model.evaluate(X_test, y_test, verbose=0)
_, acc_GRU = gru_model.evaluate(X_test, y_test, verbose=0)

# Print the results
print("SimpleRNN model's accuracy:\t{0}".format(____))
print("GRU model's accuracy:\t{0}".format(____))
แก้ไขและรันโค้ด