始める無料で始める

TensorFlow でニューラルネットワークを学習する

前の演習では、model(w1, b1, w2, b2, features) というモデルと、loss_function(w1, b1, w2, b2, features, targets) という損失関数を定義しました。どちらもこの演習で利用できます。これからモデルを学習し、test_featurestest_targets からなるテストセットでデフォルト発生の予測を行い、性能を評価します。訓練可能な変数は w1b1w2b2 です。さらに、keras.activations.relu()keras.layers.Dropout() の操作はインポート済みです。

この演習はコースの一部です

Introduction to TensorFlow in Python

コースを見る

演習の手順

  • オプティマイザを最小化を実行するように設定します。
  • loss_function() の引数として現れる順に、4つの訓練可能な変数を var_list に追加します。
  • モデルと test_features を使って、test_targets の値を予測します。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

# Train the model
for j in range(100):
    # Complete the optimizer
	opt.____(lambda: loss_function(w1, b1, w2, b2), 
                 var_list=[____, ____, ____, ____])

# Make predictions with model using test features
model_predictions = model(w1, b1, w2, b2, ____)

# Construct the confusion matrix
confusion_matrix(test_targets, model_predictions)
コードを編集して実行