今まで作ってきたトレーニング・ファイルやラベル・ファイル、テスト・ファイルやラベル・ファイルを使用して、Keras で学習させた。
まずは、course_line というディレクトリを作成し、その下にJupyter Notebook のファイルが入る course_nn2_line ディレクトリを作成した。そして、 train_course_run_image と train_course_run_label 、test_course_run_image と test_course_run_label と画像ファイルをロードする「ゼロから作るDeep Learning」のPython ファイルを使用した course_dataset.py が入っている dataset_course ディレクトリを作成した。
今までと同じネットワークで学習した。
学習画像での精度は 99.0 % だが、テスト画像での精度は 92.1 % だった。かなり離れてしまっている。
Train on 55350 samples, validate on 55800 samples
Epoch 1/2
55350/55350 [==============================] - 8s 142us/step - loss: 0.2619 - acc: 0.8985 - val_loss: 0.3540 - val_acc: 0.9143
Epoch 2/2
55350/55350 [==============================] - 8s 151us/step - loss: 0.0416 - acc: 0.9900 - val_loss: 0.3693 - val_acc: 0.9206
グラフを示す。
モデルのサーマリを示す。
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d_3 (Conv2D) (None, 6, 52, 2) 52
_________________________________________________________________
activation_7 (Activation) (None, 6, 52, 2) 0
_________________________________________________________________
max_pooling2d_3 (MaxPooling2 (None, 3, 26, 2) 0
_________________________________________________________________
flatten_3 (Flatten) (None, 156) 0
_________________________________________________________________
dense_5 (Dense) (None, 100) 15700
_________________________________________________________________
activation_8 (Activation) (None, 100) 0
_________________________________________________________________
dense_6 (Dense) (None, 3) 303
_________________________________________________________________
activation_9 (Activation) (None, 3) 0
=================================================================
Total params: 16,055
Trainable params: 16,055
Non-trainable params: 0
畳み込み層の統計情報を示す。
np.max(conv_layer_weight) = 0.6540467143058777
np.min(conv_layer_weight) = -0.6467538475990295
np.max(abs_conv_layer_weight) = 0.6540467143058777
np.min(abs_conv_layer_weight) = 0.015607763081789017
np.max(conv_layer_bias) = 0.08890005201101303
np.min(conv_layer_bias) = -0.29033342003822327
np.max(abs_conv_layer_bias) = 0.29033342003822327
np.min(abs_conv_layer_bias) = 0.08890005201101303
conv_output = (55800, 6, 52, 2)
np.std(conv_output) = 0.5240352153778076
np.max(conv_output) = 3.5787222385406494
np.min(conv_output) = -2.7464802265167236
np.max(abs_conv) = 3.5787222385406494
np.min(abs_conv) = 2.384185791015625e-07
畳み込み層の重みとバイアスのグラフを示す。
全結合層1層目の統計情報を示す。
np.max(dence_layer1_weight) = 0.4496344029903412
np.min(dence_layer1_weight) = -0.3555082380771637
np.max(abs_dence_layer1_weight) = 0.4496344029903412
np.min(abs_dence_layer1_weight) = 1.2449898349586874e-05
np.max(dence_layer1_bias) = 0.21790167689323425
np.min(dence_layer1_bias) = -0.16780713200569153
np.max(abs_dence_layer1_bias) = 0.21790167689323425
np.min(abs_dence_layer1_bias) = 5.26009825989604e-05
dence_layer1_output = (55800, 100)
np.std(dence_layer1_output) = 1.1125332117080688
np.max(dence_layer1_output) = 9.291604995727539
np.min(dence_layer1_output) = -10.281697273254395
np.max(abs_dence_layer1_output) = 10.281697273254395
np.min(abs_dence_layer1_output) = 2.682209014892578e-07
全結合層1層目の重みとバイアスのグラフを示す。
全結合2層目の統計情報を示す。
np.max(dence_layer2_weight) = 0.6938429474830627
np.min(dence_layer2_weight) = -0.8714218139648438
np.max(abs_dence_layer2_weight) = 0.8714218139648438
np.min(abs_dence_layer2_weight) = 0.0005191437667235732
np.max(dence_layer2_bias) = 0.04392116516828537
np.min(dence_layer2_bias) = -0.030551407486200333
np.max(abs_dence_layer2_bias) = 0.04392116516828537
np.min(abs_dence_layer2_bias) = 0.009192205034196377
dence_layer2_output = (55800, 3)
np.std(dence_layer2_output) = 7.362751007080078
np.max(dence_layer2_output) = 29.604900360107422
np.min(dence_layer2_output) = -32.173988342285156
np.max(abs_dence_layer2_output) = 32.173988342285156
np.min(abs_dence_layer2_output) = 0.0001368783414363861
全結合2層目の重みとバイアスのグラフを示す。
各層の重みやバイアスの C ヘッダ・ファイルを出力し、1000個のテスト画像を出力した C ヘッダ・ファイル course_line_data.h を出力した。