TensorFlow เฟรมเวิร์ก ML จาก Google Open Source ใช้กับ Python อัลกอริทึม Deep Learning งานวิจัยและ Production มีเทคนิคเพิ่มประสิทธิภาพคำนวณ ใช้ NumPy และ Multi-dimensional Arrays (Tensors) รองรับ Deep Neural Network
ติดตั้ง tensorflow บน Windows:
pip install tensorflow
Tensor โครงสร้างข้อมูลใน TensorFlow (Data Flow Graph) เป็นอาร์เรย์หลายมิติ/ลิสต์
ใช้ชุดข้อมูล Iliad (ข้อความแปล 3 ชิ้น) โมเดลระบุผู้แปลจากบรรทัดเดี่ยว ข้อมูล Preprocessed แล้ว ใช้ Google Colab รันโค้ด (Python บนเบราว์เซอร์ ฟรี GPU บน Jupyter Notebook)
ตัวอย่างโค้ด
print("Combine the labelled dataset and reshuffle it")
BUFFER_SIZE = 50000
BATCH_SIZE = 64
VALIDATION_SIZE = 5000
all_labeled_data = labeled_data_sets[0]
for labeled_dataset in labeled_data_sets[1:]:
all_labeled_data = all_labeled_data.concatenate(labeled_dataset)
all_labeled_data = all_labeled_data.shuffle(
BUFFER_SIZE, reshuffle_each_iteration=False)
print("Displaying a few samples of input data")
for text, label in all_labeled_data.take(8):
print("The sentence is : ", text.numpy())
print("The label is :", label.numpy())
Credit: TensorFlow Tutorials
ผลลัพธ์
Combine the labelled dataset and reshuffle it Displaying a few samples of input data The sentence is : b'But I have now both tasted food, and given' The label is : 0 The sentence is : b'All these shall now be thine: but if the Gods' The label is : 1 The sentence is : b'Their spiry summits waved. There, unperceived' The label is : 0 The sentence is : b'"I pray you, would you show your love, dear friends,' The label is : 1 The sentence is : b'Entering beneath the clavicle the point' The label is : 0 The sentence is : b'But grief, his father lost, awaits him now,' The label is : 1 The sentence is : b'in the fore-arm where the sinews of the elbow are united, whereon he' The label is : 2 The sentence is : b'For, as I think, I have already chased' The label is : 0
คำอธิบาย
หลัง Preprocess แสดงตัวอย่างข้อมูลบน Console
ข้อมูลไม่ได้จัดกลุ่ม (Ungrouped) ทุก Entry ใน
all_labeled_datamap ไปยัง Data Point เดียว