kerasでの画像識別分類器作成でつまづいたところ

#はじめに
kerasを使って、フルーツの画像判別の分類器を作ろうと思ったら、地味につまづいたので備忘録として残しておきます

#こちらの問題のコード

基本は[kerasの公式ページ](https://keras.io/getting-started/sequential-model-guide)のexampleのgithubを参考にしたものです。

```python
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D
from keras.layers import Activation, Dropout, Flatten, Dense
from keras.utils import np_utils
import keras
import numpy as np

classes = ["apple","banana","orange"]
num_classes = len(classes)
image_size = 50

def main():
    X_train,X_test,y_train,y_test = np.load("./fruits.npy")
    X_train = X_train.astype("float")/256
    X_test = X_test.astype("float")/256
    y_train = np_utils.to_categorical(y_train,num_classes)
    y_test = np_utils.to_categorical(y_test,num_classes)

    model = model_train(X_train,y_train)
    model_eval(model,X_test,y_test)

def model_train(X,y):

    model = Sequential()
    model.add(Conv2D(32, (3, 3), padding='same',input_shape=X.shape[1:]))
    model.add(Activation('relu'))
    model.add(Conv2D(32, (3, 3)))
    model.add(Activation('relu'))
    model.add(MaxPooling2D(pool_size=(2, 2)))
    model.add(Dropout(0.25))

    model.add(Conv2D(64, (3, 3), padding='same'))
    model.add(Activation('relu'))
    model.add(Conv2D(64, (3, 3)))
    model.add(Activation('relu'))
    model.add(MaxPooling2D(pool_size=(2, 2)))
    model.add(Dropout(0.25))

    model.add(Flatten())
    model.add(Dense(512))
    model.add(Activation('relu'))
    model.add(Dropout(0.5))
    model.add(Dense(3))
    model.add(Activation('softmax'))

# initiate RMSprop optimizer
    opt = keras.optimizers.rmsprop(lr=0.0001, decay=1e-6)

# Let's train the model using RMSprop
    model.compile(loss='categorical_crossentropy',
              optimizer=opt,
              metrics=['accuracy'])

    model.fit(X, y,batch_size=32,nb_epoch=100)

    model.save("./fruit_cnn.h5")

    return model

def model_eval(model,X,y):
    scores = model.evaluate(X,y,verbose = 1)
    print("test loss: ",scores[0])
    print("test accuracy: ",scores[1])

if __name__ == "__main__":
    main()
```

#実行した際のエラー

```terminal
$ python fruit_cnn.py
Using TensorFlow backend.
Traceback (most recent call last):
  File "fruit_cnn.py", line 66, in <module>
    main()
  File "fruit_cnn.py", line 19, in main
    model = model_train(X_train,y_train)
  File "fruit_cnn.py", line 25, in model_train
    model.add(Conv2D(32, (3, 3), padding='same',input_shape=X.shape[1:]))
  File "/Users/hoge/anaconda3/envs/tf001/lib/python3.6/site-packages/keras/engine/sequential.py", line 165, in add
    layer(x)
  File "/Users/hoge/anaconda3/envs/tf001/lib/python3.6/site-packages/keras/engine/base_layer.py", line 414, in __call__
    self.assert_input_compatibility(inputs)
  File "/Users/hoge/anaconda3/envs/tf001/lib/python3.6/site-packages/keras/engine/base_layer.py", line 311, in assert_input_compatibility
    str(K.ndim(x)))
ValueError: Input 0 is incompatible with layer conv2d_1: expected ndim=4, found ndim=1
```
#問題点

色々書いてあるけど、とにかく**ちゃんと読み込めてないよ。**ということかと理解し
中身を見てみると

```python
Keras: Exception: Received unknown keyword arguments: {'epoch': 100}
```

どうやらnb_epochsというのがバージョンで使えないとのこと。

#ということで修正

```python:修正前
model.fit(X, y,batch_size=32,nb_epochs=100)
```

```python:修正後
model.fit(X, y,batch_size=32,epochs=100)
```

無事動きました！！

#参考
[Keras: Exception: Received unknown keyword arguments: {'epochs': 100}](https://stackoverflow.com/questions/43509881/keras-exception-received-unknown-keyword-arguments-epochs-100?rq=1)
[keras sin 予測 中間層について](https://teratail.com/questions/113540)
[AI coordinator](http://ai-coordinator.jp/face-recognition)
[Googleから画像を一括でダウンロードするツール「google-images-download」](https://co.bsnws.net/article/295)