Activation functions

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

Isaiah Hull

Visiting Associate Professor of Finance, BI Norwegian Business School

Activation function คืออะไร?

  • องค์ประกอบของ hidden layer ทั่วไป
    • เชิงเส้น: การคูณเมทริกซ์
    • ไม่เชิงเส้น: Activation function
TensorFlow เบื้องต้นใน Python

เหตุใดความไม่เชิงเส้นจึงสำคัญ

ภาพแสดงเครือข่ายอย่างง่าย โดยใช้ยอดบิลและอายุในการพยากรณ์การผิดนัดชำระ

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

เหตุใดความไม่เชิงเส้นจึงสำคัญ

ภาพแสดงความสัมพันธ์ระหว่างยอดบิลบัตรเครดิตและการผิดนัดชำระสำหรับผู้กู้อายุ 30 ปีหรือน้อยกว่า

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

ตัวอย่างอย่างง่าย

import numpy as np
import tensorflow as tf

# Define example borrower features
young, old = 0.3, 0.6
low_bill, high_bill = 0.1, 0.5
# Apply matrix multiplication step for all feature combinations
young_high = 1.0*young + 2.0*high_bill
young_low = 1.0*young + 2.0*low_bill
old_high = 1.0*old + 2.0*high_bill
old_low = 1.0*old + 2.0*low_bill
TensorFlow เบื้องต้นใน Python

ตัวอย่างอย่างง่าย

# Difference in default predictions for young
print(young_high - young_low)

# Difference in default predictions for old
print(old_high - old_low)
0.8 
0.8
TensorFlow เบื้องต้นใน Python

ตัวอย่างอย่างง่าย

# Difference in default predictions for young
print(tf.keras.activations.sigmoid(young_high).numpy() - 
tf.keras.activations.sigmoid(young_low).numpy())

# Difference in default predictions for old
print(tf.keras.activations.sigmoid(old_high).numpy() - 
tf.keras.activations.sigmoid(old_low).numpy())
0.16337568
0.14204389
TensorFlow เบื้องต้นใน Python

Sigmoid activation function

  • Sigmoid activation function
    • การจำแนกประเภทแบบไบนารี
    • ระดับต่ำ: tf.keras.activations.sigmoid()
    • ระดับสูง: sigmoid

ภาพแสดงกราฟของ sigmoid activation function ในช่วง -10 ถึง 10

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

ReLU activation function

  • ReLU activation function
    • Hidden layers
    • ระดับต่ำ: tf.keras.activations.relu()
    • ระดับสูง: relu

ภาพแสดงกราฟของ relu activation function ในช่วง -10 ถึง 10

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

Softmax activation function

  • Softmax activation function
    • Output layer (>2 คลาส)
    • ระดับต่ำ: tf.keras.activations.softmax()
    • ระดับสูง: softmax
TensorFlow เบื้องต้นใน Python

Activation functions ในโครงข่ายประสาทเทียม

import tensorflow as tf
# Define input layer
inputs = tf.constant(borrower_features, tf.float32)
# Define dense layer 1
dense1 = tf.keras.layers.Dense(16, activation='relu')(inputs)
# Define dense layer 2
dense2 = tf.keras.layers.Dense(8, activation='sigmoid')(dense1)
# Define output layer 
outputs = tf.keras.layers.Dense(4, activation='softmax')(dense2)
TensorFlow เบื้องต้นใน Python

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

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

Preparing Video For Download...