Activatiefuncties

Introductie tot TensorFlow in Python

Isaiah Hull

Visiting Associate Professor of Finance, BI Norwegian Business School

Wat is een activatiefunctie?

  • Onderdelen van een typische verborgen laag
    • Lineair: matrixvermenigvuldiging
    • Niet-lineair: activatiefunctie
Introductie tot TensorFlow in Python

Waarom niet-lineariteit belangrijk is

Deze afbeelding toont een simpel netwerk waar het bedrag op de rekening en leeftijd wanbetaling voorspellen.

Introductie tot TensorFlow in Python

Waarom niet-lineariteit belangrijk is

Deze afbeelding toont de relatie tussen het bedrag op de creditcardrekening en wanbetaling voor leners van 30 en jonger.

Introductie tot TensorFlow in Python

Een simpel voorbeeld

import numpy as np
import tensorflow as tf

# Voorbeeldkenmerken van leners
young, old = 0.3, 0.6
low_bill, high_bill = 0.1, 0.5
# Pas matrixvermenigvuldiging toe voor alle combinaties
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
Introductie tot TensorFlow in Python

Een simpel voorbeeld

# Verschil in wanbetalingsvoorspellingen voor jong
print(young_high - young_low)

# Verschil in wanbetalingsvoorspellingen voor oud
print(old_high - old_low)
0.8 
0.8
Introductie tot TensorFlow in Python

Een simpel voorbeeld

# Verschil in wanbetalingsvoorspellingen voor jong
print(tf.keras.activations.sigmoid(young_high).numpy() - 
tf.keras.activations.sigmoid(young_low).numpy())

# Verschil in wanbetalingsvoorspellingen voor oud
print(tf.keras.activations.sigmoid(old_high).numpy() - 
tf.keras.activations.sigmoid(old_low).numpy())
0.16337568
0.14204389
Introductie tot TensorFlow in Python

De sigmoid-activatiefunctie

  • Sigmoid-activatie
    • Binaire classificatie
    • Low-level: tf.keras.activations.sigmoid()
    • High-level: sigmoid

De afbeelding toont een grafiek van de sigmoid-activatiefunctie over het interval -10 tot 10.

Introductie tot TensorFlow in Python

De ReLU-activatiefunctie

  • ReLU-activatie
    • Verborgen lagen
    • Low-level: tf.keras.activations.relu()
    • High-level: relu

De afbeelding toont een grafiek van de ReLU-activatiefunctie over het interval -10 tot 10.

Introductie tot TensorFlow in Python

De softmax-activatiefunctie

  • Softmax-activatie
    • Uitvoerlaag (>2 klassen)
    • Low-level: tf.keras.activations.softmax()
    • High-level: softmax
Introductie tot TensorFlow in Python

Activatiefuncties in neurale netwerken

import tensorflow as tf
# Definieer invoerlaag
inputs = tf.constant(borrower_features, tf.float32)
# Definieer dense-laag 1
dense1 = tf.keras.layers.Dense(16, activation='relu')(inputs)
# Definieer dense-laag 2
dense2 = tf.keras.layers.Dense(8, activation='sigmoid')(dense1)
# Definieer uitvoerlaag 
outputs = tf.keras.layers.Dense(4, activation='softmax')(dense2)
Introductie tot TensorFlow in Python

Laten we oefenen!

Introductie tot TensorFlow in Python

Preparing Video For Download...