{"cells":[{"metadata":{"trusted":true,"_uuid":"565f054e8c232349d0df5c7dd9b702fa8cc943f2"},"cell_type":"code","source":"import pandas as pd\n\nfile=pd.read_csv('../input/train_labels.csv')\nd=dict()\nfor i in range(220025) :\n    d[file.iloc[i][0]]=file.iloc[i][1]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"95e2d535928878b1ef708b84eeed267952b88038"},"cell_type":"code","source":"import numpy as np","execution_count":null,"outputs":[]},{"metadata":{"trusted":false,"_uuid":"2888bf70417d7e4070c88643f5388e7636a729a1"},"cell_type":"code","source":"a=dict()\na['one']=1\nprint(a)","execution_count":null,"outputs":[]},{"metadata":{"trusted":false,"_uuid":"2f5594d30e12940d07942e827b82cd7fc0ea319c"},"cell_type":"code","source":"a['two']=2\nprint(a)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"3351bb9a46c2aa62330d90e5b452d645666a580f"},"cell_type":"code","source":"import cv2\nfrom os.path import join\nfrom os import listdir","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4323133735d4f3098d070df67437d7ce1e4cd8f7"},"cell_type":"code","source":"feature= []\nlabel = []\npath= \"../input/train/\"\nfor f in listdir(path):\n    print(join(path, f))\n    img = cv2.imread(join(path, f))\n    resized_img = cv2.resize(img, (48,48))\n    feature.append(resized_img)\n    label.append(d[f.split(\".\")[-2]])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0bab6ebf62f9db4bfbdd00800abd6299d4604e8f"},"cell_type":"code","source":"feature = np.asarray(feature).reshape(220025,48,48,3)","execution_count":null,"outputs":[]},{"metadata":{"trusted":false,"_uuid":"9b79e7a852fbbe8ddbd9bb08f2869c07db9e78de"},"cell_type":"code","source":"feature = pd.DataFrame()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"78275e68d7370158468e6ecda844f9c091854d0b"},"cell_type":"code","source":"len(feature[0])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9c70c79f259f4734134cba2ea7449b2b2d513554"},"cell_type":"code","source":"feature = (feature-128)/255","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e140683d1b6cc903b2b8828cd41e82535b026bee"},"cell_type":"code","source":"from keras.models import Sequential\nfrom keras.layers import MaxPooling2D, Conv2D, Flatten, Activation, BatchNormalization, Dense\nimport keras","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6d91621c1e7f1ee4bb7aa7aba87c23ea87978636"},"cell_type":"code","source":"model = Sequential()\n\nmodel.add(Conv2D(32, input_shape=feature.shape[1:], kernel_size=(3,3), padding=\"valid\"))\nmodel.add(Activation(\"relu\"))\nmodel.add(MaxPooling2D(pool_size=(3,3)))\n\nmodel.add(Conv2D(128, kernel_size=(3,3), padding=\"valid\"))\nmodel.add(Activation(\"relu\"))\nmodel.add(MaxPooling2D(pool_size=(3,3)))\n\nmodel.add(Dense(64))\n\nmodel.add(Flatten())\n\nmodel.add(Dense(1))\n\nmodel.compile(loss=\"binary_crossentropy\",\n             optimizer=keras.optimizers.Adamax(lr=5, decay=0.1),\n             metrics=[\"acc\"])","execution_count":null,"outputs":[]},{"metadata":{"scrolled":true,"trusted":true,"_uuid":"087fc3f7703bf8360df06502dedd92945abb36f0"},"cell_type":"code","source":"model.fit(feature, label, epochs=5, batch_size=32, validation_split=0.1)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d397012d510cb475f7b753fb087f2f7ff067b9c7"},"cell_type":"code","source":"label = np.asarray(label).reshape(220025,1)","execution_count":null,"outputs":[]},{"metadata":{"trusted":false,"_uuid":"7561c48e0b98dc697de78886b568b04327e89c30"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":false,"_uuid":"f3544abfcf1c417cd8bbf2c5900f9f08e3a1943f"},"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.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}