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

การสร้าง Dataset ของ Raw Strings จาก Iliad Dataset ด้วย TensorFlow


บทนำ

TensorFlow เฟรมเวิร์ก ML จาก Google โค้ดเปิด ใช้กับ Python ใช้ในงานวิจัยและการผลิต

การติดตั้ง

pip install tensorflow

Tensor และชุดข้อมูล Iliad

เทนเซอร์ = อาร์เรย์หลายมิติ สำหรับ Data flow graph Iliad: ข้อความ 3 งานแปลของ Cowper, Derby, Butler ฝึกระบุผู้แปลจากบรรทัดเดียว ข้อความผ่าน preprocessing แล้ว

ตัวอย่าง: สร้าง Test Dataset และ Evaluate

print("สร้าง Test Dataset จาก Raw Strings")
test_ds = all_labeled_data.take(VALIDATION_SIZE).batch(BATCH_SIZE)
test_ds = configure_dataset(test_ds)

loss, accuracy = export_model.evaluate(test_ds)
print("Loss:", loss)
print("Accuracy: {:2.2%}".format(accuracy))

ที่มา: TensorFlow Text Loading Tutorial

ผลลัพธ์

สร้าง Test Dataset จาก Raw Strings
79/79 [==============================] - 7s 10ms/step - loss: 0.5230 - accuracy: 0.7909
Loss: 0.5458346605300903
Accuracy: 78.16%

คำอธิบาย

  • สร้าง Test dataset โดย取 (take) จำนวน VALIDATION_SIZE และ batch ด้วย BATCH_SIZE
  • ผ่าน configure_dataset เพื่อเตรียมข้อมูล
  • ประเมินด้วย evaluate ได้ loss และ accuracy
  • แสดงผลบนคอนโซล