Tensorflow Google द्वारा प्रदान किया गया एक मशीन लर्निंग फ्रेमवर्क है। यह एक ओपन-सोर्स फ्रेमवर्क है जिसे Python के साथ संयोजन में एल्गोरिदम, डीप लर्निंग एप्लिकेशन और बहुत कुछ लागू करने के लिए उपयोग किया जाता है। इसका उपयोग शोध और उत्पादन उद्देश्यों के लिए किया जाता है।
Keras को ONEIROS (ओपन-एंडेड न्यूरो-इलेक्ट्रॉनिक इंटेलिजेंट रोबोट ऑपरेटिंग सिस्टम) प्रोजेक्ट के शोध के हिस्से के रूप में विकसित किया गया था। Keras एक डीप लर्निंग API है, जो Python में लिखा गया है। यह एक हाई-लेवल API है जिसमें एक उत्पादक इंटरफ़ेस है जो मशीन लर्निंग समस्याओं को हल करने में मदद करता है। यह Tensorflow फ्रेमवर्क के शीर्ष पर चलता है। इसे त्वरित प्रयोग में मदद करने के लिए बनाया गया था। यह आवश्यक अमूर्तता और बिल्डिंग ब्लॉक प्रदान करता है जो मशीन लर्निंग समाधानों को विकसित और एनकैप्सुलेट करने में आवश्यक हैं।
Keras पहले से ही Tensorflow पैकेज के भीतर मौजूद है। इसे नीचे दिए गए कोड की लाइन का उपयोग करके एक्सेस किया जा सकता है।
import tensorflow from tensorflow import keras
Keras फंक्शनल API Sequential API का उपयोग करके बनाए गए मॉडल की तुलना में अधिक लचीले मॉडल बनाने में मदद करता है। फंक्शनल API नॉन-लीनियर टोपोलॉजी वाले मॉडल के साथ काम कर सकता है, लेयर्स साझा कर सकता है और कई इनपुट और आउटपुट के साथ काम कर सकता है। एक डीप लर्निंग मॉडल आमतौर पर एक डायरेक्टेड एसाइक्लिक ग्राफ (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 का उपयोग कई इनपुट और आउटपुट के साथ काम करने के लिए किया जा सकता है।
यह Sequential API के साथ नहीं किया जा सकता।