{"cells":[{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"b72e85e2-cbd3-6f4d-aa80-60f6a151e35c"},"outputs":[],"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\n\nfrom subprocess import check_output\nprint(check_output([\"ls\", \"../input\"]).decode(\"utf8\"))\n\n# Any results you write to the current directory are saved as output."},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"d3d1509c-65c8-f7ef-f94c-446e160dcadb"},"outputs":[],"source":"import numpy as np\nimport pandas as pd\nimport cv2\nimport math\nimport pickle\nimport datetime\nimport os\nimport glob"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"75fb7b47-cd13-a44b-d96a-d8ab54039226"},"outputs":[],"source":"from sklearn.cross_validation import train_test_split\nfrom sklearn.cross_validation import KFold\nfrom keras.models import Sequential\nfrom keras.layers.core import Dense, Dropout, Activation, Flatten\nfrom keras.layers.convolutional import Convolution2D, MaxPooling2D, ZeroPadding2D\nfrom keras.layers.convolutional import Conv2D, ZeroPadding2D\n#from keras.layers.pooling import MaxPooling2D\nfrom keras.optimizers import SGD\nfrom keras.utils import np_utils\nfrom keras.models import model_from_json\nfrom sklearn.metrics import log_loss\nfrom scipy.misc import imread, imresize"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"8bd20905-8462-b0a5-7484-97e59b784c9b"},"outputs":[],"source":"def get_im_cv2(path, img_rows, img_cols, color_type=1):\n    # Load as grayscale\n    if color_type == 1:\n        img = cv2.imread(path, 0)\n    elif color_type == 3:\n        img = cv2.imread(path)\n    # Reduce size\n    resized = cv2.resize(img, (img_cols, img_rows))\n    return resized"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"ccca14c9-3bde-db1e-afc0-e18e5e318cdd"},"outputs":[],"source":"def get_train_data():\n    dr = dict()\n    path = os.path.join(\"../\", 'driver_imgs_list.csv')\n    print('Read drivers data')\n    f = open(path, 'r')\n    line = f.readline()\n    while (1):\n        line = f.readline()\n        if line == '':\n            break\n        arr = line.strip().split(',')\n        dr[arr[2]] = arr[0]\n    f.close()\n    return dr"}],"metadata":{"_change_revision":0,"_is_fork":false,"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.6.0"}},"nbformat":4,"nbformat_minor":0}