Kayıp fonksiyonları

Python ile TensorFlow’a Giriş

Isaiah Hull

Visiting Associate Professor of Finance, BI Norwegian Business School

Kayıp fonksiyonlarına giriş

  • Temel tensorflow işlemi
    • Modeli eğitmek için kullanılır
    • Model uyumunun ölçüsü
  • Değer yükseldikçe -> uyum kötüleşir
    • Kayıp fonksiyonunu en aza indirin
Python ile TensorFlow’a Giriş

TensorFlow’daki yaygın kayıp fonksiyonları

  • TensorFlow yaygın kayıp fonksiyonları için işlemler sunar

    • Ortalama kare hata (MSE)
    • Ortalama mutlak hata (MAE)
    • Huber hatası
  • Kayıp fonksiyonları tf.keras.losses() ile erişilebilir

    • tf.keras.losses.mse()
    • tf.keras.losses.mae()
    • tf.keras.losses.Huber()
Python ile TensorFlow’a Giriş

Kayıp fonksiyonlarını neden önemseriz?

Bu görsel, -2 ile 2 aralığında çizilen mse, mae ve huber kayıp fonksiyonlarını gösterir.

  • MSE
    • Aykırı değerlere güçlü ceza
    • Minimuma yakın yüksek (gradyan) duyarlılık
  • MAE
    • Hata boyutuyla doğrusal artar
    • Minimuma yakın düşük duyarlılık
  • Huber
    • Minimuma yakın MSE’ye benzer
    • Minimumdan uzakta MAE’ye benzer
Python ile TensorFlow’a Giriş

Kayıp fonksiyonu tanımlama

# Import TensorFlow under standard alias
import tensorflow as tf

# Compute the MSE loss
loss = tf.keras.losses.mse(targets, predictions)
Python ile TensorFlow’a Giriş

Kayıp fonksiyonu tanımlama

# 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 ile TensorFlow’a Giriş

Kayıp fonksiyonunu tanımlama

# 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 ile TensorFlow’a Giriş

Hadi pratik yapalım!

Python ile TensorFlow’a Giriş

Preparing Video For Download...