{"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\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\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 the files in the input directory\nimport cv2\nimport os\nprint(os.listdir(\"../input\"))\n\n# Any results you write to the current directory are saved as output.","execution_count":1,"outputs":[{"output_type":"stream","text":"['test', 'labels.csv', 'sample_submission.csv', 'train']\n","name":"stdout"}]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"%ls '../input/'\nlabels=pd.read_csv('../input/labels.csv')\ntest=pd.read_csv('../input/sample_submission.csv')","execution_count":2,"outputs":[{"output_type":"stream","text":"labels.csv  sample_submission.csv  \u001b[0m\u001b[01;34mtest\u001b[0m/  \u001b[01;34mtrain\u001b[0m/\r\n","name":"stdout"}]},{"metadata":{"trusted":true},"cell_type":"code","source":"path=labels['id']\ntarget1=labels['breed']\ntestpath=test['id']","execution_count":3,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"target=target1.append(target1)\ntarget=target.append(target)","execution_count":4,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"from keras.preprocessing.image import load_img,img_to_array\nimage_train1=[]\nfor x in path:\n    y=cv2.imread('../input/train/'+x+'.jpg')\n    y=cv2.resize(y,(64,64))\n    y=np.array(y).flatten()\n    image_train1.append(y)","execution_count":5,"outputs":[{"output_type":"stream","text":"Using TensorFlow backend.\n","name":"stderr"}]},{"metadata":{"trusted":true},"cell_type":"code","source":"image_test=[]\nfor x in testpath:\n    y=cv2.imread('../input/test/'+x+'.jpg')\n    y=cv2.resize(y,(64,64))\n    y=np.array(y).flatten()\n    image_test.append(y)","execution_count":6,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"image_train=np.array(image_train1)\nimage_test=np.array(image_test)","execution_count":7,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"image_train=np.append(image_train,image_train,0)\nimage_train=np.append(image_train,image_train,0)","execution_count":8,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"target_all=pd.get_dummies(target,sparse=True)\ntarget=np.asarray(target_all)","execution_count":9,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"from keras.layers import Dense,Dropout,Flatten\nfrom sklearn.model_selection import train_test_split as tts\nxtrain,xtest,ztrain,ztest=tts(image_train,target,train_size=0.8)","execution_count":10,"outputs":[{"output_type":"stream","text":"/opt/conda/lib/python3.6/site-packages/sklearn/model_selection/_split.py:2179: FutureWarning: From version 0.21, test_size will always complement train_size unless both are specified.\n  FutureWarning)\n","name":"stderr"}]},{"metadata":{"trusted":true},"cell_type":"code","source":"from keras.layers import Conv2D\nfrom keras.models import Sequential\nmodel=Sequential()\nmodel.add(Dense(1000, activation = \"tanh\"))\nmodel.add(Dropout(0.1))\nmodel.add(Dense(500, activation = \"relu\"))\nmodel.add(Dropout(0.1))\nmodel.add(Dense(120, activation = \"softmax\"))","execution_count":11,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"model.compile(loss='categorical_crossentropy',optimizer='adam',metrics=['accuracy'])","execution_count":12,"outputs":[{"output_type":"stream","text":"WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\nInstructions for updating:\nColocations handled automatically by placer.\n","name":"stdout"}]},{"metadata":{"trusted":true},"cell_type":"code","source":"history=model.fit(xtrain,ztrain, batch_size=5000, epochs=10)","execution_count":13,"outputs":[{"output_type":"stream","text":"WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:3445: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.\nInstructions for updating:\nPlease use `rate` instead of `keep_prob`. Rate should be set to `rate = 1 - keep_prob`.\nWARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.\nInstructions for updating:\nUse tf.cast instead.\nEpoch 1/10\n32710/32710 [==============================] - 20s 608us/step - loss: 5.0584 - acc: 0.0091\nEpoch 2/10\n32710/32710 [==============================] - 18s 540us/step - loss: 4.7966 - acc: 0.0096\nEpoch 3/10\n32710/32710 [==============================] - 18s 540us/step - loss: 4.7858 - acc: 0.0110\nEpoch 4/10\n32710/32710 [==============================] - 18s 538us/step - loss: 4.7851 - acc: 0.0105\nEpoch 5/10\n32710/32710 [==============================] - 18s 537us/step - loss: 4.7847 - acc: 0.0124\nEpoch 6/10\n32710/32710 [==============================] - 18s 549us/step - loss: 4.7839 - acc: 0.0109\nEpoch 7/10\n32710/32710 [==============================] - 18s 538us/step - loss: 4.7818 - acc: 0.0115\nEpoch 8/10\n32710/32710 [==============================] - 18s 539us/step - loss: 4.7807 - acc: 0.0120\nEpoch 9/10\n32710/32710 [==============================] - 18s 537us/step - loss: 4.7802 - acc: 0.0114\nEpoch 10/10\n32710/32710 [==============================] - 18s 539us/step - loss: 4.7774 - acc: 0.0121\n","name":"stdout"}]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.4","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}