Tensorflow คือเฟรมเวิร์กแมชชีนเลิร์นนิงที่ให้บริการโดย Google เป็นเฟรมเวิร์กโอเพนซอร์สที่ใช้ร่วมกับ Python เพื่อใช้อัลกอริทึม แอปพลิเคชันการเรียนรู้เชิงลึก และอื่นๆ อีกมากมาย ใช้ในการวิจัยและเพื่อการผลิต
แพ็คเกจ 'tensorflow' สามารถติดตั้งบน Windows ได้โดยใช้บรรทัดโค้ดด้านล่าง -
pip install tensorflow
Tensor เป็นโครงสร้างข้อมูลที่ใช้ใน TensorFlow ช่วยเชื่อมต่อขอบในแผนภาพการไหล แผนภาพการไหลนี้เรียกว่า 'กราฟการไหลของข้อมูล' เทนเซอร์เป็นเพียงอาร์เรย์หลายมิติหรือรายการ
เรากำลังใช้ Google Colaboratory เพื่อเรียกใช้โค้ดด้านล่าง Google Colab หรือ Colaboratory ช่วยเรียกใช้โค้ด Python บนเบราว์เซอร์และไม่ต้องมีการกำหนดค่าใดๆ และเข้าถึง GPU ได้ฟรี (หน่วยประมวลผลกราฟิก) การทำงานร่วมกันถูกสร้างขึ้นบน Jupyter Notebook
ตัวอย่าง
ต่อไปนี้เป็นข้อมูลโค้ด -
print("Testing the model with new data")
inputs = [
"how do I extract keys from a dict into a list?",
"debug public static void main(string[] args) {...}",
]
print("Predicting the scores ")
predicted_scores = export_model.predict(inputs)
print("Predicting the labels")
predicted_labels = get_string_labels(predicted_scores)
for input, label in zip(inputs, predicted_labels):
print("Question is: ", input)
print("The predicted label is : ", label.numpy()) เครดิตโค้ด - https://www.tensorflow.org/tutorials/load_data/text
ผลลัพธ์
Testing the model with new data
Predicting the scores
Predicting the labels
Question is: how do I extract keys from a dict into a list?
The predicted label is : b'python'
Question is: debug public static void main(string[] args) {...}
The predicted label is : b'java' คำอธิบาย
-
เมื่อมีโค้ดประมวลผลข้อความล่วงหน้าอยู่ภายในโมเดล จะช่วยส่งออกโมเดลสำหรับการผลิต
-
วิธีนี้จะทำให้การปรับใช้ง่ายขึ้น
-
เมื่อใช้ 'TextVectorization' นอกโมเดล จะช่วยดำเนินการประมวลผล CPU แบบอะซิงโครนัสและการบัฟเฟอร์