Optimizers

Introductie tot TensorFlow in Python

Isaiah Hull

Visiting Associate Professor of Finance, BI Norwegian Business School

Hoe vind je een minimum

De afbeelding toont de Grand Canyon.

1 Bron: U.S. National Park Service
Introductie tot TensorFlow in Python

Hoe vind je een minimum

De afbeelding toont de Grand Canyon.

1 Bron: U.S. National Park Service
Introductie tot TensorFlow in Python

Hoe vind je een minimum

De afbeelding toont de Grand Canyon.

1 Bron: U.S. National Park Service
Introductie tot TensorFlow in Python

De figuur toont het leerpad van de optimizers SGD, RMSprop en Adam voor een eenvoudig probleem.

Introductie tot TensorFlow in Python

De gradient-descent-optimizer

  • Stochastic gradient descent (SGD) optimizer

    • tf.keras.optimizers.SGD()
    • learning_rate
  • Simpel en goed te begrijpen

Introductie tot TensorFlow in Python

De RMSprop-optimizer

  • Root mean squared (RMS) propagation-optimizer

    • Past per feature een andere learning rate toe
    • tf.keras.optimizers.RMSprop()
    • learning_rate
    • momentum
    • decay
  • Laat momentum zowel opbouwen als afnemen

Introductie tot TensorFlow in Python

De Adam-optimizer

  • Adaptive moment (Adam) optimizer

    • tf.keras.optimizers.Adam()
    • learning_rate
    • beta1
  • Presteert goed met standaardwaarden

Introductie tot TensorFlow in Python

Een volledig voorbeeld

import tensorflow as tf

# Define the model function
def model(bias, weights, features = borrower_features):
    product = tf.matmul(features, weights)
    return tf.keras.activations.sigmoid(product+bias)
# Compute the predicted values and loss
def loss_function(bias, weights, targets = default, features = borrower_features):
    predictions = model(bias, weights)
    return tf.keras.losses.binary_crossentropy(targets, predictions)
# Minimize the loss function with RMS propagation
opt = tf.keras.optimizers.RMSprop(learning_rate=0.01, momentum=0.9)
opt.minimize(lambda: loss_function(bias, weights), var_list=[bias, weights])
Introductie tot TensorFlow in Python

Laten we oefenen!

Introductie tot TensorFlow in Python

Preparing Video For Download...