始める無料で始める

ニューロンの分離

手術用の手袋をはめて、脳外科手術に取りかかりましょう!

ニューロンは、重みを更新して出力値を調整し、データセット内の異なる出力クラスをよりよく見分けられるように学習します。 さきほど作成した inp_to_out() 関数を使って、学習の過程で Banknote Authenticationmodel にある最初の層の2つのニューロンの出力を可視化します。

チャプター2で作成した model は、X_testy_test と同様にすぐに使える状態です。plot() を確認したい場合は、コンソールに show_code(plot) を貼り付けてください。

計算が重い処理です。完了したら、グラフをクリックして、分離が進む様子をライブで見てみましょう!

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

Kerasで学ぶIntroduction to Deep Learning

コースを見る

演習の手順

  • 先ほど定義した inp_to_out() 関数を使い、X_test を入力したときの最初の層の出力を取得します。
  • 各エポックにおけるテストデータセットでの検証精度を得るために、model.evaluate() メソッドを使用します。

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

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

for i in range(0, 21):
  	# Train model for 1 epoch
    h = model.fit(X_train, y_train, batch_size = 16, epochs = 1, verbose = 0)
    if i%4==0: 
      # Get the output of the first layer
      layer_output = ____([____])[0]
      
      # Evaluate model accuracy for this epoch
      test_accuracy = model.____(____, ____)[1] 
      
      # Plot 1st vs 2nd neuron output
      plot()
コードを編集して実行