Tensorflow คือเฟรมเวิร์กแมชชีนเลิร์นนิงที่ให้บริการโดย Google เป็นเฟรมเวิร์กโอเพนซอร์สที่ใช้ร่วมกับ Python เพื่อใช้อัลกอริทึม แอปพลิเคชันการเรียนรู้เชิงลึก และอื่นๆ อีกมากมาย ใช้ในการวิจัยและเพื่อการผลิต
Keras ได้รับการพัฒนาโดยเป็นส่วนหนึ่งของการวิจัยสำหรับโครงการ ONEIROS (ระบบปฏิบัติการหุ่นยนต์อัจฉริยะ Neuro-Electronic ปลายเปิด) Keras เป็น API การเรียนรู้เชิงลึกซึ่งเขียนด้วยภาษา Python เป็น API ระดับสูงที่มีอินเทอร์เฟซที่มีประสิทธิภาพซึ่งช่วยแก้ปัญหาการเรียนรู้ของเครื่อง มันทำงานบนเฟรมเวิร์ก Tensorflow มันถูกสร้างขึ้นเพื่อช่วยทดลองในลักษณะที่รวดเร็ว โดยนำเสนอสิ่งที่เป็นนามธรรมและการสร้างบล็อคที่จำเป็นต่อการพัฒนาและการห่อหุ้มโซลูชันแมชชีนเลิร์นนิง
Keras มีอยู่แล้วในแพ็คเกจ Tensorflow สามารถเข้าถึงได้โดยใช้รหัสบรรทัดด้านล่าง
import tensorflow from tensorflow import keras
Keras functional API ช่วยสร้างโมเดลที่มีความยืดหยุ่นมากกว่าเมื่อเปรียบเทียบกับโมเดลที่สร้างโดยใช้ Sequential API API ที่ใช้งานได้สามารถทำงานกับโมเดลที่มีโทโพโลยีที่ไม่ใช่เชิงเส้น สามารถแชร์เลเยอร์และทำงานกับอินพุตและเอาต์พุตได้หลายรายการ โมเดลการเรียนรู้เชิงลึกมักจะเป็นกราฟ acyclic แบบกำกับทิศทาง (DAG) ที่มีหลายเลเยอร์ API การทำงานช่วยสร้างกราฟของเลเยอร์
เรากำลังใช้ Google Colaboratory เพื่อเรียกใช้โค้ดด้านล่าง Google Colab หรือ Colaboratory ช่วยเรียกใช้โค้ด Python บนเบราว์เซอร์และไม่ต้องมีการกำหนดค่าใดๆ และเข้าถึง GPU ได้ฟรี (หน่วยประมวลผลกราฟิก) Colaboratory ถูกสร้างขึ้นบน Jupyter Notebook ต่อไปนี้เป็นข้อมูลโค้ดที่เราจะฝังทุกคำในชื่อเป็นเวกเตอร์ 64 มิติ -
ตัวอย่าง
print("Number of unique issue tags")
num_tags = 12
print("Size of vocabulary while preprocessing text data")
num_words = 10000
print("Number of classes for predictions")
num_classes = 4
title_input = keras.Input(
shape=(None,), name="title"
)
print("Variable length int sequence")
body_input = keras.Input(shape=(None,), name="body")
tags_input = keras.Input(
shape=(num_tags,), name="tags"
)
print("Embed every word in the title to a 64-dimensional vector")
title_features = layers.Embedding(num_words, 64)(title_input)
print("Embed every word into a 64-dimensional vector")
body_features = layers.Embedding(num_words, 64)(body_input)
print("Reduce sequence of embedded words into single 128-dimensional vector")
title_features = layers.LSTM(128)(title_features)
print("Reduce sequence of embedded words into single 132-dimensional vector")
body_features = layers.LSTM(32)(body_features)
print("Merge available features into a single vector by concatenating it")
x = layers.concatenate([title_features, body_features, tags_input])
print("Use logistic regression to predict the features")
priority_pred = layers.Dense(1, name="priority")(x)
department_pred = layers.Dense(num_classes, name="class")(x)
print("Instantiate a model that predicts priority and class")
model = keras.Model(
inputs=[title_input, body_input, tags_input],
outputs=[priority_pred, department_pred],
) เครดิตโค้ด – https://www.tensorflow.org/guide/keras/functional
ผลลัพธ์
Number of unique issue tags Size of vocabulary while preprocessing text data Number of classes for predictions Variable length int sequence Embed every word in the title to a 64-dimensional vector Embed every word into a 64-dimensional vector Reduce sequence of embedded words into single 128-dimensional vector Reduce sequence of embedded words into single 132-dimensional vector Merge available features into a single vector by concatenating it Use logistic regression to predict the features Instantiate a model that predicts priority and class
คำอธิบาย
-
สามารถใช้ API การทำงานเพื่อทำงานกับอินพุตและเอาต์พุตหลายรายการได้
-
ไม่สามารถทำได้ด้วย API ตามลำดับ