TensorFlow でニューラルネットワークを学習する
前の演習では、model(w1, b1, w2, b2, features) というモデルと、loss_function(w1, b1, w2, b2, features, targets) という損失関数を定義しました。どちらもこの演習で利用できます。これからモデルを学習し、test_features と test_targets からなるテストセットでデフォルト発生の予測を行い、性能を評価します。訓練可能な変数は w1、b1、w2、b2 です。さらに、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)