การฝึกโครงข่ายประสาทเทียมใน TensorFlow

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

Isaiah Hull

Visiting Associate Professor of Finance, BI Norwegian Business School

ภาพแสดงกราฟ 3D ของฟังก์ชันวัตถุประสงค์ที่ซับซ้อนเรียกว่า eggholder function

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

Random initializers

  • มักต้องกำหนดค่าเริ่มต้นให้กับตัวแปรนับพัน
    • tf.ones() อาจให้ผลลัพธ์ที่ไม่ดี
    • การกำหนดค่าทีละตัวแปรนั้นยุ่งยากและเสียเวลา
  • อีกทางเลือกคือสุ่มค่าเริ่มต้นจากการแจกแจง
    • Normal
    • Uniform
    • Glorot initializer
TensorFlow เบื้องต้นใน Python

การกำหนดค่าเริ่มต้นของตัวแปรใน TensorFlow

import tensorflow as tf

# Define 500x500 random normal variable
weights = tf.Variable(tf.random.normal([500, 500]))

# Define 500x500 truncated random normal variable
weights = tf.Variable(tf.random.truncated_normal([500, 500]))
TensorFlow เบื้องต้นใน Python

การกำหนดค่าเริ่มต้นของตัวแปรใน TensorFlow

# Define a dense layer with the default initializer
dense = tf.keras.layers.Dense(32, activation='relu')

# Define a dense layer with the zeros initializer
dense = tf.keras.layers.Dense(32, activation='relu',\
    kernel_initializer='zeros')
TensorFlow เบื้องต้นใน Python

โครงข่ายประสาทเทียมกับการ overfitting

ภาพแสดงผลการทำนายของโมเดลแบบเรียบง่ายและซับซ้อนบนชุดข้อมูล training

ภาพแสดงผลการทำนายของโมเดลแบบเรียบง่ายและซับซ้อนบนชุดข้อมูล validation

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

การใช้งาน dropout

ภาพแสดงโครงข่ายประสาทเทียมที่ยังไม่ได้ใช้ dropout

ภาพแสดงโครงข่ายประสาทเทียมที่ใช้ dropout กับโหนดที่สุ่มเลือก

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

การนำ dropout ไปใช้ในโครงข่าย

import numpy as np
import tensorflow as tf

# Define input data
inputs = np.array(borrower_features, np.float32)
# Define dense layer 1
dense1 = tf.keras.layers.Dense(32, activation='relu')(inputs)
TensorFlow เบื้องต้นใน Python

การนำ dropout ไปใช้ในโครงข่าย

# Define dense layer 2
dense2 = tf.keras.layers.Dense(16, activation='relu')(dense1)
# Apply dropout operation
dropout1 = tf.keras.layers.Dropout(0.25)(dense2)
# Define output layer
outputs = tf.keras.layers.Dense(1, activation='sigmoid')(dropout1)
TensorFlow เบื้องต้นใน Python

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

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

Preparing Video For Download...