{"cells":[{"cell_type":"code","execution_count":null,"metadata":{"collapsed":false},"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%matplotlib inline\nimport matplotlib.pyplot as plt\nimport matplotlib.cm as cm\n\nimport tensorflow as tf\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":{"collapsed":false},"outputs":[],"source":"LEARNING_RATE = 1e-4\nTRAINING_ITERATIONS = 2500\n\nDROPOUT = 0.5\nBATCH_SIZE = 50\n\nVALIDATION_SIZE = 2000\n\nIMAGE_TO_DISPLAY = 10"},{"cell_type":"code","execution_count":null,"metadata":{"collapsed":false},"outputs":[],"source":"data = pd.read_csv('../input/train.csv')\n\nprint('data({0[0]},{0[1]})'.format(data.shape))\nprint(data.head())"},{"cell_type":"code","execution_count":null,"metadata":{"collapsed":false},"outputs":[],"source":"print(data.iloc[:, 1:].head())\nimages = data.iloc[:, 1:].values\nimages = images.astype(np.float)\nprint(images)"},{"cell_type":"code","execution_count":null,"metadata":{"collapsed":false},"outputs":[],"source":"images = np.multiply(images, 1.0/255.0)\nprint(images)"},{"cell_type":"code","execution_count":null,"metadata":{"collapsed":false},"outputs":[],"source":"print('images({0[0]},{0[1]})'.format(images.shape))"},{"cell_type":"code","execution_count":null,"metadata":{"collapsed":false},"outputs":[],"source":"image_size = images.shape[1]\nprint('image_size => {0}'.format(image_size))"},{"cell_type":"code","execution_count":null,"metadata":{"collapsed":false},"outputs":[],"source":"image_width = image_height = np.ceil(np.sqrt(image_size)).astype(np.uint8)\nprint('image_width => {0}\\nimage_height => {1}'.format(image_width, image_height))"},{"cell_type":"code","execution_count":null,"metadata":{"collapsed":false},"outputs":[],"source":"def display(img):\n    one_image = img.reshape(image_width, image_height)\n    \n    plt.axis('off')\n    plt.imshow(one_image, cmap=cm.binary)\n    \ndisplay(images[IMAGE_TO_DISPLAY])"},{"cell_type":"code","execution_count":null,"metadata":{"collapsed":false},"outputs":[],"source":"labels_flat = data[[0]].values.ravel()\n\nprint('labels_flat({0})'.format(len(labels_flat)))\nprint('labels_flat[{0}] => {1}'.format(IMAGE_TO_DISPLAY, labels_flat[IMAGE_TO_DISPLAY]))"},{"cell_type":"code","execution_count":null,"metadata":{"collapsed":false},"outputs":[],"source":""}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"}},"nbformat":4,"nbformat_minor":0}