TensorFlowでネットワークを学習

Introduction to TensorFlow in Python

Isaiah Hull

Visiting Associate Professor of Finance, BI Norwegian Business School

エッグホルダー関数と呼ばれる複雑な目的関数の3Dプロット。

Introduction to TensorFlow in Python

ランダム初期化子

  • 多くの場合、数千の変数を初期化
    • tf.ones()は性能が悪いことがある
    • 個別初期化は手間で難しい
  • 代わりに分布から初期値をサンプリング
    • 正規分布
    • 一様分布
    • Glorot初期化
Introduction to TensorFlow in 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]))
Introduction to TensorFlow in 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')
Introduction to TensorFlow in Python

ニューラルネットと過学習

学習データにおける単純モデルと複雑モデルの予測。

検証データにおける単純モデルと複雑モデルの予測。

Introduction to TensorFlow in Python

ドロップアウトの適用

ドロップアウトなしのニューラルネットワークの図。

ランダムなノードにドロップアウトを適用したニューラルネットワークの図。

Introduction to TensorFlow in Python

ネットワークへのドロップアウト実装

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)
Introduction to TensorFlow in Python

ネットワークへのドロップアウト実装

# 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)
Introduction to TensorFlow in Python

Let's practice!

Introduction to TensorFlow in Python

Preparing Video For Download...