लॉस फंक्शन्स

Python में TensorFlow परिचय

Isaiah Hull

Visiting Associate Professor of Finance, BI Norwegian Business School

लॉस फंक्शन्स का परिचय

  • मूलभूत tensorflow ऑपरेशन
    • मॉडल ट्रेन करने के लिए उपयोग होता है
    • मॉडल फिट का माप
  • मान अधिक -> फिट खराब
    • लॉस फंक्शन को न्यूनतम करें
Python में TensorFlow परिचय

TensorFlow में सामान्य लॉस फंक्शन्स

  • TensorFlow में सामान्य लॉस फंक्शन्स के ऑपरेशन्स हैं

    • Mean squared error (MSE)
    • Mean absolute error (MAE)
    • Huber error
  • लॉस फंक्शन्स tf.keras.losses() से उपलब्ध हैं

    • tf.keras.losses.mse()
    • tf.keras.losses.mae()
    • tf.keras.losses.Huber()
Python में TensorFlow परिचय

लॉस फंक्शन्स क्यों महत्वपूर्ण हैं?

यह इमेज -2 से 2 अंतराल में प्लॉट किए गए mse, mae और huber लॉस फंक्शन्स दिखाती है.

  • MSE
    • आउट्लायर्स को कड़ा दंड देता है
    • न्यूनतम के पास (ग्रेडिएंट) संवेदनशीलता अधिक
  • MAE
    • त्रुटि के आकार के साथ रैखिक रूप से बढ़ता है
    • न्यूनतम के पास संवेदनशीलता कम
  • Huber
    • न्यूनतम के पास MSE जैसा
    • न्यूनतम से दूर MAE जैसा
Python में TensorFlow परिचय

लॉस फंक्शन परिभाषित करना

# Import TensorFlow under standard alias
import tensorflow as tf

# Compute the MSE loss
loss = tf.keras.losses.mse(targets, predictions)
Python में TensorFlow परिचय

लॉस फंक्शन परिभाषित करना

# Define a linear regression model
def linear_regression(intercept, slope = slope, features = features):
    return intercept + features*slope
# Define a loss function to compute the MSE
def loss_function(intercept, slope, targets = targets, features = features):
    # Compute the predictions for a linear model
    predictions = linear_regression(intercept, slope)

    # Return the loss
    return tf.keras.losses.mse(targets, predictions)
Python में TensorFlow परिचय

लॉस फंक्शन परिभाषित करना

# Compute the loss for test data inputs
loss_function(intercept, slope, test_targets, test_features)
10.77
# Compute the loss for default data inputs
loss_function(intercept, slope)
5.43
Python में TensorFlow परिचय

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

Python में TensorFlow परिचय

Preparing Video For Download...