Optimizatori

Introducere în TensorFlow în Python

Isaiah Hull

Visiting Associate Professor of Finance, BI Norwegian Business School

Cum se găsește un minim

Imaginea prezintă Marele Canion.

1 Sursă: U.S. National Park Service
Introducere în TensorFlow în Python

Cum se găsește un minim

Imaginea prezintă Marele Canion.

1 Sursă: U.S. National Park Service
Introducere în TensorFlow în Python

Cum se găsește un minim

Imaginea prezintă Marele Canion.

1 Sursă: U.S. National Park Service
Introducere în TensorFlow în Python

Figura arată traiectoria de învățare a optimizatorilor SGD, RMS prop și Adam pentru o problemă simplă.

Introducere în TensorFlow în Python

Optimizatorul gradient descendent

  • Optimizatorul gradient descendent stochastic (SGD)

    • tf.keras.optimizers.SGD()
    • learning_rate
  • Simplu și ușor de interpretat

Introducere în TensorFlow în Python

Optimizatorul RMS prop

  • Optimizatorul RMS propagation

    • Aplică rate de învățare diferite pentru fiecare caracteristică
    • tf.keras.optimizers.RMSprop()
    • learning_rate
    • momentum
    • decay
  • Permite acumularea și diminuarea impulsului

Introducere în TensorFlow în Python

Optimizatorul Adam

  • Optimizatorul moment adaptiv (Adam)

    • tf.keras.optimizers.Adam()
    • learning_rate
    • beta1
  • Funcționează bine cu valorile implicite ale parametrilor

Introducere în TensorFlow în Python

Un exemplu complet

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])
Introducere în TensorFlow în Python

Să exersăm!

Introducere în TensorFlow în Python

Preparing Video For Download...