Funcții de activare

Introducere în TensorFlow în Python

Isaiah Hull

Visiting Associate Professor of Finance, BI Norwegian Business School

Ce este o funcție de activare?

  • Componentele unui strat ascuns tipic
    • Liniar: Înmulțire matriceală
    • Neliniar: Funcție de activare
Introducere în TensorFlow în Python

De ce sunt importante nelinioritățile

Imaginea prezintă o rețea simplă în care suma facturii și vârsta sunt folosite pentru a prezice implicit.

Introducere în TensorFlow în Python

De ce sunt importante nelinioritățile

Imaginea prezintă relația dintre suma facturii cardului de credit și implicit pentru debitorii cu vârsta de 30 de ani sau mai mică.

Introducere în TensorFlow în Python

Un exemplu simplu

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

Un exemplu simplu

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

Un exemplu simplu

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

Funcția de activare sigmoid

  • Funcția de activare sigmoid
    • Clasificare binară
    • Nivel scăzut: tf.keras.activations.sigmoid()
    • Nivel înalt: sigmoid

Imaginea prezintă graficul funcției de activare sigmoid pe intervalul -10 la 10.

Introducere în TensorFlow în Python

Funcția de activare ReLU

  • Funcția de activare ReLU
    • Straturi ascunse
    • Nivel scăzut: tf.keras.activations.relu()
    • Nivel înalt: relu

Imaginea prezintă graficul funcției de activare ReLU pe intervalul -10 la 10.

Introducere în TensorFlow în Python

Funcția de activare softmax

  • Funcția de activare softmax
    • Strat de ieșire (>2 clase)
    • Nivel scăzut: tf.keras.activations.softmax()
    • Nivel înalt: softmax
Introducere în TensorFlow în Python

Funcții de activare în rețele neuronale

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

Să exersăm!

Introducere în TensorFlow în Python

Preparing Video For Download...