Optimizers

TensorFlow เบื้องต้นใน Python

Isaiah Hull

Visiting Associate Professor of Finance, BI Norwegian Business School

การหาจุดต่ำสุด

ภาพแสดง Grand Canyon

1 ที่มา: U.S. National Park Service
TensorFlow เบื้องต้นใน Python

การหาจุดต่ำสุด

ภาพแสดง Grand Canyon

1 ที่มา: U.S. National Park Service
TensorFlow เบื้องต้นใน Python

การหาจุดต่ำสุด

ภาพแสดง Grand Canyon

1 ที่มา: U.S. National Park Service
TensorFlow เบื้องต้นใน Python

กราฟแสดงเส้นทางการเรียนรู้ของ optimizer แบบ SGD, RMSprop และ Adam สำหรับปัญหาอย่างง่าย

TensorFlow เบื้องต้นใน Python

Gradient descent optimizer

  • Stochastic gradient descent (SGD) optimizer

    • tf.keras.optimizers.SGD()
    • learning_rate
  • เรียบง่ายและตีความได้ง่าย

TensorFlow เบื้องต้นใน Python

RMS prop optimizer

  • Root mean squared (RMS) propagation optimizer

    • ปรับ learning rate แยกตามแต่ละฟีเจอร์
    • tf.keras.optimizers.RMSprop()
    • learning_rate
    • momentum
    • decay
  • รองรับทั้งการสะสมและการลดลงของ momentum

TensorFlow เบื้องต้นใน Python

Adam optimizer

  • Adaptive moment (adam) optimizer

    • tf.keras.optimizers.Adam()
    • learning_rate
    • beta1
  • ทำงานได้ดีด้วยค่าพารามิเตอร์เริ่มต้น

TensorFlow เบื้องต้นใน Python

ตัวอย่างแบบครบถ้วน

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])
TensorFlow เบื้องต้นใน Python

มาฝึกกันเถอะ!

TensorFlow เบื้องต้นใน Python

Preparing Video For Download...