Estimators API के साथ मॉडल ट्रेनिंग

Python में TensorFlow परिचय

Isaiah Hull

Visiting Associate Professor of Finance, BI Norwegian Business School

Estimators API क्या है?

  • हाई-लेवल सबमॉड्यूल
  • कम लचीला
  • सर्वोत्तम प्रैक्टिस लागू करता है
  • तेज़ डिप्लॉयमेंट
  • कई प्रीमेड मॉडल

यह छवि Estimators API का स्कीमैटिक और लोअर-लेवल APIs से उसका संबंध दिखाती है.

1 Image taken from https://www.tensorflow.org/guide/premade_estimators
Python में TensorFlow परिचय

मॉडल स्पेसिफिकेशन और ट्रेनिंग

  1. फीचर कॉलम परिभाषित करें
  2. डेटा लोड करें और ट्रांसफॉर्म करें
  3. एक estimator परिभाषित करें
  4. train ऑपरेशन चलाएँ
Python में TensorFlow परिचय

फीचर कॉलम परिभाषित करना

# Import tensorflow under its standard alias
import tensorflow as tf

# Define a numeric feature column
size = tf.feature_column.numeric_column("size")
# Define a categorical feature column
rooms = tf.feature_column.categorical_column_with_vocabulary_list("rooms",\
["1", "2", "3", "4", "5"])
Python में TensorFlow परिचय

फीचर कॉलम परिभाषित करना

# Create feature column list
features_list = [size, rooms]
# Define a matrix feature column
features_list = [tf.feature_column.numeric_column('image', shape=(784,))]
Python में TensorFlow परिचय

डेटा लोड और ट्रांसफॉर्म करना

# Define input data function
def input_fn():
    # Define feature dictionary
    features = {"size": [1340, 1690, 2720], "rooms": [1, 3, 4]}
    # Define labels
    labels = [221900, 538000, 180000]
    return features, labels
Python में TensorFlow परिचय

रेग्रेशन estimator परिभाषित करें और ट्रेन करें

# Define a deep neural network regression
model0 = tf.estimator.DNNRegressor(feature_columns=feature_list,\
    hidden_units=[10, 6, 6, 3])

# Train the regression model
model0.train(input_fn, steps=20)
Python में TensorFlow परिचय

डीप न्यूरल नेटवर्क परिभाषित करें और ट्रेन करें

# Define a deep neural network classifier
model1 = tf.estimator.DNNClassifier(feature_columns=feature_list,\ 
   hidden_units=[32, 16, 8], n_classes=4)

# Train the classifier
model1.train(input_fn, steps=20)
Python में TensorFlow परिचय

अभ्यास करते हैं!

Python में TensorFlow परिचय

Preparing Video For Download...