TensorFlow เป็นเฟรมเวิร์ก ML จาก Google Open Source ใช้กับ Python สำหรับอัลกอริทึม Deep Learning งานวิจัยและ Production
ติดตั้ง tensorflow บน Windows:
pip install tensorflow
Tensor คือโครงสร้างข้อมูลใน TensorFlow (Data Flow Graph) เป็นอาร์เรย์หลายมิติ/ลิสต์
ใช้ชุดข้อมูล Iliad (ข้อความแปล 3 ชิ้น) โมเดลระบุผู้แปลจากบรรทัดเดี่ยว ข้อมูล Preprocessed แล้ว (ลบ Header, Footer, หมายเลขบรรทัด, ชื่อบท) ใช้ Google Colab รันโค้ด (Python บนเบราว์เซอร์ ฟรี GPU บน Jupyter Notebook)
ตัวอย่าง
print("Look at sample data after processing it")
example_text, example_label = next(iter(all_labeled_data))
print("The sentence is : ", example_text.numpy())
vectorized_text, example_label = preprocess_text(example_text, example_label)
print("The vectorized sentence is : ", vectorized_text.numpy())
print("Run the pre-process function on the data")
all_encoded_data = all_labeled_data.map(preprocess_text)
Credit: TensorFlow Tutorials
ผลลัพธ์
Look at sample data after processing it The sentence is : b'But I have now both tasted food, and given' The vectorized sentence is : [ 20 21 58 49 107 3497 909 2 4 540] Run the pre-process function on the data
คำอธิบาย
หลัง Vectorize ทุก Token จะถูกแปลงเป็น Integer
แปลงเป็น Integer เพื่อให้โมเดลตีความ Input ได้