บทนำ
TensorFlow เฟรมเวิร์ก ML จาก Google โค้ดเปิด ใช้กับ Python ใช้ในงานวิจัยและการผลิต
การติดตั้ง
pip install tensorflow
Tensor และปัญหา Regression
เทนเซอร์ = อาร์เรย์หลายมิติ สำหรับ Data flow graph ปัญหา Regression: ทำนายตัวแปรต่อเนื่อง
ชุดข้อมูล Auto MPG
ข้อมูลรถยนต์ยุค 70-80s คุณสมบัติ: น้ำหนัก แรงม้า ปริมาตรเครื่องยนต์ ฯลฯ ทำนาย MPG
ตัวอย่าง: ฟังก์ชันพล็อต Loss และการประเมิน
def plot_loss(history):
plt.plot(history.history['loss'], label='loss')
plt.plot(history.history['val_loss'], label='val_loss')
plt.ylim([0, 10])
plt.xlabel('Epoch')
plt.ylabel('Error [MPG]')
plt.legend()
plt.grid(True)
plot_loss(history)
test_results = {}
test_results['hrspwr_model'] = hrspwr_model.evaluate(
test_features['Horsepower'],
test_labels, verbose=0)
ที่มาโค้ด: TensorFlow Regression Tutorial
ผลลัพธ์

คำอธิบาย
- ใช้ฟังก์ชัน
evaluateเพื่อวัดประสิทธิภาพโมเดลกับข้อมูลที่ไม่เคยเห็นมาก่อน - แสดงผลลัพธ์บนคอนโซล