ニューラルネットワーク(AI)はプラレール新幹線をどれだけ分類できるのか Part.2

前回の「[Part1](https://qiita.com/ichigoryume/items/0a59217bb548c19c5e7b)」では、用意した画像が単純すぎたためか単純なニューラルネットワークにもかかわらず正解率が１００％になってしまったので、もう少し難しそうな画像を増やして正解率を下げることにする。

# さらに１０００枚ほど撮影
- 背景が異なる画像を含めたほうが難易度があがるかと考え、車両を駅に配置して撮影した
- 車両に物体が重なっていると難易度が上がると考え、車両に踏切のバーを重ねて撮影した

![](https://cdn-ak.f.st-hatena.com/images/fotolife/i/ichigoryume/20190122/20190122110201.png)
![](https://cdn-ak.f.st-hatena.com/images/fotolife/i/ichigoryume/20190122/20190122113012.png)

# その他変更点
- 学習速度をあげるため、画像サイズを約半分の241x181（=43621）に落とした
- これに伴ってエポックを10000から30000に増やした。バッチ数は100のまま。
- 画像数が約2300ほどになったため、テスト用画像を100枚から200枚に増やした

#結果、正解率は91%まで低下
- 思惑通り。
- 誤差はエポック25000辺りでそれ以上下がらなくなったため、現在のネットワークではこれがほぼ限界と思われる。

```:log
Step: 100, Loss: 279.984619, Accuracy: 0.495000
Step: 200, Loss: 263.182739, Accuracy: 0.430000
Step: 300, Loss: 245.329498, Accuracy: 0.580000
Step: 400, Loss: 232.737030, Accuracy: 0.585000
Step: 500, Loss: 225.712845, Accuracy: 0.600000
Step: 600, Loss: 217.859879, Accuracy: 0.630000
Step: 700, Loss: 211.969482, Accuracy: 0.625000
Step: 800, Loss: 206.160675, Accuracy: 0.635000
Step: 900, Loss: 202.111359, Accuracy: 0.680000
Step: 1000, Loss: 197.932663, Accuracy: 0.655000
Step: 1100, Loss: 206.351227, Accuracy: 0.645000
Step: 1200, Loss: 190.835083, Accuracy: 0.675000
Step: 1300, Loss: 187.031219, Accuracy: 0.675000
Step: 1400, Loss: 184.327316, Accuracy: 0.710000
Step: 1500, Loss: 183.411179, Accuracy: 0.685000
Step: 1600, Loss: 178.068787, Accuracy: 0.700000
Step: 1700, Loss: 175.691254, Accuracy: 0.725000
Step: 1800, Loss: 173.498672, Accuracy: 0.705000
Step: 1900, Loss: 173.270248, Accuracy: 0.715000
Step: 2000, Loss: 168.690918, Accuracy: 0.730000

 中略

Step: 23000, Loss: 77.118477, Accuracy: 0.895000
Step: 23100, Loss: 76.649017, Accuracy: 0.900000
Step: 23200, Loss: 75.812241, Accuracy: 0.910000
Step: 23300, Loss: 77.520264, Accuracy: 0.890000
Step: 23400, Loss: 75.159637, Accuracy: 0.900000
Step: 23500, Loss: 75.606369, Accuracy: 0.905000
Step: 23600, Loss: 75.852448, Accuracy: 0.905000
Step: 23700, Loss: 75.952690, Accuracy: 0.900000
Step: 23800, Loss: 75.298721, Accuracy: 0.910000
Step: 23900, Loss: 76.614449, Accuracy: 0.890000
Step: 24000, Loss: 75.930054, Accuracy: 0.895000
Step: 24100, Loss: 75.068802, Accuracy: 0.915000
Step: 24200, Loss: 76.302185, Accuracy: 0.895000
Step: 24300, Loss: 76.356293, Accuracy: 0.890000
Step: 24400, Loss: 75.714508, Accuracy: 0.900000
Step: 24500, Loss: 76.272682, Accuracy: 0.905000
Step: 24600, Loss: 74.408127, Accuracy: 0.910000
Step: 24700, Loss: 75.521187, Accuracy: 0.900000
Step: 24800, Loss: 75.205093, Accuracy: 0.905000
Step: 24900, Loss: 76.792297, Accuracy: 0.900000
Step: 25000, Loss: 78.416946, Accuracy: 0.890000
Step: 25100, Loss: 75.455780, Accuracy: 0.910000
Step: 25200, Loss: 76.358658, Accuracy: 0.895000
Step: 25300, Loss: 75.759972, Accuracy: 0.895000
Step: 25400, Loss: 76.104073, Accuracy: 0.905000
Step: 25500, Loss: 75.919937, Accuracy: 0.895000
Step: 25600, Loss: 75.418106, Accuracy: 0.900000
Step: 25700, Loss: 76.525047, Accuracy: 0.900000
Step: 25800, Loss: 75.517799, Accuracy: 0.900000
Step: 25900, Loss: 75.164856, Accuracy: 0.910000
Step: 26000, Loss: 76.757790, Accuracy: 0.895000
Step: 26100, Loss: 75.461182, Accuracy: 0.915000
Step: 26200, Loss: 76.967758, Accuracy: 0.895000
Step: 26300, Loss: 75.115715, Accuracy: 0.910000
Step: 26400, Loss: 75.610611, Accuracy: 0.905000
Step: 26500, Loss: 74.960861, Accuracy: 0.910000
Step: 26600, Loss: 75.156906, Accuracy: 0.905000
Step: 26700, Loss: 75.497498, Accuracy: 0.910000
Step: 26800, Loss: 75.899231, Accuracy: 0.900000
Step: 26900, Loss: 77.876091, Accuracy: 0.890000
Step: 27000, Loss: 76.708344, Accuracy: 0.895000
Step: 27100, Loss: 76.526398, Accuracy: 0.895000
Step: 27200, Loss: 75.636887, Accuracy: 0.895000
Step: 27300, Loss: 73.997955, Accuracy: 0.905000
Step: 27400, Loss: 74.746841, Accuracy: 0.910000
Step: 27500, Loss: 76.067230, Accuracy: 0.905000
Step: 27600, Loss: 74.706421, Accuracy: 0.905000
Step: 27700, Loss: 77.650581, Accuracy: 0.895000
Step: 27800, Loss: 73.584564, Accuracy: 0.910000
Step: 27900, Loss: 75.304855, Accuracy: 0.895000
Step: 28000, Loss: 75.567368, Accuracy: 0.905000
Step: 28100, Loss: 74.589310, Accuracy: 0.910000
Step: 28200, Loss: 75.442429, Accuracy: 0.905000
Step: 28300, Loss: 75.010147, Accuracy: 0.910000
Step: 28400, Loss: 74.773842, Accuracy: 0.900000
Step: 28500, Loss: 74.487991, Accuracy: 0.910000
Step: 28600, Loss: 76.644142, Accuracy: 0.895000
Step: 28700, Loss: 74.261665, Accuracy: 0.910000
Step: 28800, Loss: 73.428802, Accuracy: 0.910000
Step: 28900, Loss: 75.442459, Accuracy: 0.900000
Step: 29000, Loss: 76.467438, Accuracy: 0.895000
Step: 29100, Loss: 74.068748, Accuracy: 0.910000
Step: 29200, Loss: 75.063889, Accuracy: 0.905000
Step: 29300, Loss: 74.606766, Accuracy: 0.900000
Step: 29400, Loss: 75.346062, Accuracy: 0.895000
Step: 29500, Loss: 73.825851, Accuracy: 0.905000
Step: 29600, Loss: 74.331100, Accuracy: 0.905000
Step: 29700, Loss: 73.107620, Accuracy: 0.910000
Step: 29800, Loss: 74.090782, Accuracy: 0.910000
Step: 29900, Loss: 75.115509, Accuracy: 0.900000
Step: 30000, Loss: 73.798546, Accuracy: 0.910000
```

# 不正解画像
## 手振れなどで画像がぼやけているもの
![](https://cdn-ak.f.st-hatena.com/images/fotolife/i/ichigoryume/20190122/20190122110403.png)

## 画質はわるくなく、人間なら簡単にわかるもの
![](https://cdn-ak.f.st-hatena.com/images/fotolife/i/ichigoryume/20190122/20190122110604.png)

##考察
- 自信満々でまちがえるケースが多い。
- 不正解になるケースは今回あらたに撮影した画像が多いので、やはり背景物や重なっている物体などがあると分類が難しくなるのだろう。
- 前回撮影し正解できていた（と思われる）画像で不正解だったケースは2枚。今回の重みとバイアスでは判断できなくなったということか。

# 次回
ほどよく認識率がさがってくれたので、[次回は隠れ層を追加し、層やノード数を変えながら実験する。](https://qiita.com/ichigoryume/items/249108e60096f1e10111)