Tensorflow คือเฟรมเวิร์กแมชชีนเลิร์นนิงที่ให้บริการโดย Google เป็นเฟรมเวิร์กโอเพนซอร์สที่ใช้ร่วมกับ Python เพื่อใช้อัลกอริทึม แอปพลิเคชันการเรียนรู้เชิงลึก และอื่นๆ อีกมากมาย ใช้ในการวิจัยและเพื่อการผลิต มีเทคนิคการเพิ่มประสิทธิภาพที่ช่วยในการดำเนินการทางคณิตศาสตร์ที่ซับซ้อนได้อย่างรวดเร็ว
เนื่องจากใช้ NumPy และอาร์เรย์หลายมิติ อาร์เรย์หลายมิติเหล่านี้เรียกอีกอย่างว่า 'เทนเซอร์' เฟรมเวิร์กรองรับการทำงานกับโครงข่ายประสาทเทียมระดับลึก สามารถปรับขนาดได้สูงและมาพร้อมกับชุดข้อมูลยอดนิยมมากมาย ใช้การคำนวณ GPU และจัดการทรัพยากรโดยอัตโนมัติ มันมาพร้อมกับไลบรารีการเรียนรู้ของเครื่องจำนวนมาก และได้รับการสนับสนุนและจัดทำเป็นเอกสารอย่างดี เฟรมเวิร์กมีความสามารถในการใช้งานโมเดล Deep Neural Network ฝึกอบรม และสร้างแอปพลิเคชันที่คาดการณ์ลักษณะที่เกี่ยวข้องของชุดข้อมูลที่เกี่ยวข้อง
แพ็คเกจ 'tensorflow' สามารถติดตั้งบน Windows ได้โดยใช้บรรทัดโค้ดด้านล่าง -
pip install tensorflow
เรากำลังใช้ Google Colaboratory เพื่อเรียกใช้โค้ดด้านล่าง Google Colab หรือ Colaboratory ช่วยเรียกใช้โค้ด Python บนเบราว์เซอร์และไม่ต้องมีการกำหนดค่าใดๆ และเข้าถึง GPU ได้ฟรี (หน่วยประมวลผลกราฟิก) การทำงานร่วมกันถูกสร้างขึ้นบน Jupyter Notebook ต่อไปนี้เป็นข้อมูลโค้ดสำหรับโหลดชุดข้อมูลซึ่งมีคำถาม StackOverflow โดยใช้ Python -
ตัวอย่าง
batch_size = 32 seed = 42 print("The training parameters have been defined") raw_train_ds = preprocessing.text_dataset_from_directory( train_dir, batch_size=batch_size, validation_split=0.25, subset='training', seed=seed) for text_batch, label_batch in raw_train_ds.take(1): for i in range(10): print("Question: ", text_batch.numpy()[i][:100], '...') print("Label:", label_batch.numpy()[i])
เครดิตโค้ด – https://www.tensorflow.org/tutorials/load_data/text
ผลลัพธ์
The training parameters have been defined Found 8000 files belonging to 4 classes. Using 6000 files for training. Question: b'"my tester is going to the wrong constructor i am new to programming so if i ask a question that can' ... Label: 1 Question: b'"blank code slow skin detection this code changes the color space to lab and using a threshold finds' ... Label: 3 Question: b'"option and validation in blank i want to add a new option on my system where i want to add two text' ... Label: 1 Question: b'"exception: dynamic sql generation for the updatecommand is not supported against a selectcommand th' ... Label: 0 Question: b'"parameter with question mark and super in blank, i\'ve come across a method that is formatted like t' ... Label: 1 Question: b'call two objects wsdl the first time i got a very strange wsdl. ..i would like to call the object (i' ... Label: 0 Question: b'how to correctly make the icon for systemtray in blank using icon sizes of any dimension for systemt' ... Label: 0 Question: b'"is there a way to check a variable that exists in a different script than the original one? i\'m try' ... Label: 3 Question: b'"blank control flow i made a number which asks for 2 numbers with blank and responds with the corre' ... Label: 0 Question: b'"credentials cannot be used for ntlm authentication i am getting org.apache.commons.httpclient.auth.' ... Label: 1
คำอธิบาย
-
ข้อมูลถูกโหลดออกจากดิสก์และเตรียมให้อยู่ในรูปแบบที่เหมาะสมกับการฝึกอบรม
-
ยูทิลิตี "text_dataset_from_dataset" ใช้เพื่อสร้างชุดข้อมูลที่มีป้ายกำกับ
-
'tf.Data' คือชุดเครื่องมือที่มีประสิทธิภาพและใช้ในการสร้างไพพ์ไลน์อินพุต
-
โครงสร้างไดเร็กทอรีถูกส่งไปยังยูทิลิตี้ "text_dataset_from_dataset"
-
ชุดข้อมูลคำถาม StackOverflow แบ่งออกเป็นชุดข้อมูลการฝึกอบรมและทดสอบ
-
ชุดการตรวจสอบความถูกต้องถูกสร้างขึ้นโดยใช้วิธีการ "validation_split"
-
ป้ายกำกับจะเป็น 0 หรือ 1 หรือ 2 หรือ 3