神經分離
戴上手套,因為你要來動腦部手術了!
神經元會透過更新權重,讓輸出值更能區分資料集中不同的輸出類別。
你將使用剛剛建立的 inp_to_out() 函式,來視覺化 Banknote Authentication model 第一層中兩個神經元在學習過程中的輸出。
你在第 2 章建立的 model 已經可以直接使用,X_test 和 y_test 也都就緒。如果想確認 plot(),可以在主控台貼上 show_code(plot) 查看。
你要執行的是高強度的工作;全部完成後,點擊瀏覽各張圖表,就能即時看到分離的變化!
本練習屬於課程
Keras 深度學習入門
練習說明
- 使用先前定義的
inp_to_out()函式,輸入X_test,取得第一層的輸出。 - 使用
model.evaluate()方法,在每個 epoch 取得測試資料集的驗證準確率。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
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()