{"cells":[{"cell_type":"markdown","metadata":{"_cell_guid":"d146ee10-bf79-1bfe-d1c6-453401c9bf47"},"source":"I'm going to adapt code from a previously developed Keras model using Theano to evaluate the MNIST handwritten digit data set. I'm mostly doing this to get a data point up on kaggle, as well as to try out their new notebooks feature. Just getting my feet wet :) "},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"19d2c794-5280-51df-5a62-13c119d289f4"},"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":"7985d9bb-8870-2623-e2d4-42f98ea3d049"},"outputs":[],"source":"%matplotlib inline\nfrom matplotlib import pyplot as plt\nfrom scipy.misc import imread\n#This is simply a linear stack of neural network layers, and it's perfect for the type of feed-forward CNN we're building in this tutorial.\nfrom keras.models import Sequential\n# These are the layers that are used in almost any neural network:\nfrom keras.layers import Dense, Dropout, Activation, Flatten\n#These are the convolutional layers that will help us efficiently train on image data:\nfrom keras.layers import Convolution2D, MaxPooling2D\n#helpful utilities\nfrom keras.utils import np_utils"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"97d26407-3e9e-ace0-c097-db5d9717d711"},"outputs":[],"source":"np.random.seed(123) #For reproducability with the tutorial."},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"d7e48535-68d1-9a4d-8b58-760b201d3f4d"},"outputs":[],"source":"import os\nroot_dir = os.path.abspath('../')\ndata_dir = os.path.join(root_dir, 'input')\n\n# check for existence\nos.path.exists(root_dir)"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"f6ac26cf-b0bc-2e7a-3b12-bf7505b26e75"},"outputs":[],"source":"train = pd.read_csv(os.path.join(data_dir, 'train.csv'))\ntest = pd.read_csv(os.path.join(data_dir, 'test.csv'))"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"204f3e34-9290-53b0-957c-92e6612fbe84"},"outputs":[],"source":"test.head()"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"ba42e3f9-187c-e3eb-927d-452b986c2696"},"outputs":[],"source":"train.shape"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"8ca82f9f-05c0-f512-cfa6-02e0d485c855"},"outputs":[],"source":""}],"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.5.2"}},"nbformat":4,"nbformat_minor":0}