Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีใช้ Keras พล็อตโมเดลเป็นกราฟและแสดง Input/Output Shapes ด้วย Python

TensorFlow: ML Framework Google Open-source Optimization คณิตศาสตร์ซับซ้อน Tensor = Multi-dimensional array ใน Data Flow Graph

Keras: Deep Learning API Python จาก ONEIROS รันบน TensorFlow Scalable, Cross-platform (TPU, GPU, Web, Mobile) เข้าถึงด้วย from tensorflow import keras

Functional API

ยืดหยุ่นกว่า Sequential API รองรับ Non-linear topology, Shared layers, Multiple I/O สร้าง DAG ของเลเยอร์

ตัวอย่าง: พล็อตโมเดล พร้อมแสดง Shapes

print("Plotting the built model")
keras.utils.plot_model(model, "my_model.png")

print("Displaying dimensions of input and output data")
keras.utils.plot_model(model, "my_first_model.png", show_shapes=True)

Code credit: TensorFlow Keras Functional Guide

ผลลัพธ์

วิธีใช้ Keras พล็อตโมเดลเป็นกราฟและแสดง Input/Output Shapes ด้วย Python

คำอธิบาย

  • Graph of Layers เป็น Mental Image ของ Deep Learning Model ที่ Functional API สร้างได้
  • plot_model() แสดงโครงสร้างเป็นภาพ
  • show_shapes=True แสดงขนาด Input/Output ของแต่ละเลเยอร์