Een netwerk trainen in TensorFlow

Introductie tot TensorFlow in Python

Isaiah Hull

Visiting Associate Professor of Finance, BI Norwegian Business School

De afbeelding toont een 3D-plot van een complexe doelfunctie, de eggholder-functie.

Introductie tot TensorFlow in Python

Willekeurige initializers

  • Vaak duizenden variabelen initialiseren
    • tf.ones() kan slecht presteren
    • Los per variabele initialiseren is saai en foutgevoelig
  • Alternatief: trek startwaarden uit een verdeling
    • Normaal
    • Uniform
    • Glorot-initializer
Introductie tot TensorFlow in Python

Variabelen initialiseren in 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]))
Introductie tot TensorFlow in Python

Variabelen initialiseren in 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')
Introductie tot TensorFlow in Python

Neurale netwerken en overfitting

De afbeelding toont voorspellingen van simpele en complexe modellen op de trainingsset.

De afbeelding toont voorspellingen van simpele en complexe modellen op de validatieset.

Introductie tot TensorFlow in Python

Dropout toepassen

Deze afbeelding toont een neuraal netwerk zonder dropout.

Deze afbeelding toont een neuraal netwerk met dropout op willekeurige knooppunten.

Introductie tot TensorFlow in Python

Dropout implementeren in een netwerk

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)
Introductie tot TensorFlow in Python

Dropout implementeren in een netwerk

# 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)
Introductie tot TensorFlow in Python

Laten we oefenen!

Introductie tot TensorFlow in Python

Preparing Video For Download...