{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \n\n%pip install keras-rectified-adam\nimport keras\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nfrom matplotlib import pyplot as plt # chart plotting\nimport matplotlib.image as mpimg # image presentation\nfrom PIL import Image # image resizing\n\nfrom sklearn.metrics import confusion_matrix,accuracy_score,log_loss\nimport seaborn as sns\n\nfrom keras.models import Model, Sequential\nfrom keras.datasets import mnist\nfrom keras.layers import Dense, Conv2D, Flatten, Input, AvgPool2D,MaxPool2D,Dropout\nfrom keras.utils import to_categorical\nfrom keras_radam import RAdam \nimport warnings\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\n\ntrain_dirname, _, train_filenames = list(os.walk('/kaggle/input/dog-breed-identification/train'))[0]\ntest_dirname, _, test_filenames = list(os.walk('/kaggle/input/dog-breed-identification/test'))[0]\n\ntest_size = len(test_filenames)\ntrain_size = len(train_filenames)\n\n\n\n# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"train_path = '/kaggle/input/dog-breed-identification/train/'\ntest_path = '/kaggle/input/dog-breed-identification/test/'\n\n\n#img = Image.open(train_path + filenames[10])\n#img = img.resize((300,300))\n#plt.imshow(img)\n#plt.show()\n#img_np = np.array(img)\n\nimg_col = []\n\ndf = pd.read_csv('/kaggle/input/dog-breed-identification/labels.csv')\nfor index, row in df.iterrows():\n    img = Image.open(train_path + row['id'] + '.jpg')\n    img_col.append(img.resize((300,300)))\n    \ndf['image'] = img_col\n\ndf.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"X_train = [np.asarray(img) for img in df['image']]\ny_train = df['breed']\ndf = pd.get_dummies(df, columns=['breed'],drop_first=True)\ndf.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"model = Sequential()\nmodel.add(Conv2D(32,(3,3),activation='relu',input_shape=(10222,300,300)))\nmodel.add(Conv2D(32,(3,3),activation='relu'))\nmodel.add(Flatten())\nmodel.add(Dense(120,activation='softmax'))\nmodel.compile(loss='categorical_crossentropy',optimizer='adam',metrics=['accuracy'])\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"print(X_train[0].shape)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"model.fit(X_train,\n    y_train,\n    batch_size=140,\n    epochs=3,\n    verbose=1,\n    callbacks=None,\n    validation_split=0.3)","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}