{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":3649,"databundleVersionId":46718,"sourceType":"competition"}],"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"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\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nfrom tensorflow import keras\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-05-15T06:51:36.763873Z","iopub.execute_input":"2024-05-15T06:51:36.764344Z","iopub.status.idle":"2024-05-15T06:51:36.774081Z","shell.execute_reply.started":"2024-05-15T06:51:36.764301Z","shell.execute_reply":"2024-05-15T06:51:36.772824Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"(x_train,y_train),(x_test,y_test) = keras.datasets.cifar10.load_data()","metadata":{"execution":{"iopub.status.busy":"2024-05-15T06:51:36.776768Z","iopub.execute_input":"2024-05-15T06:51:36.777326Z","iopub.status.idle":"2024-05-15T06:51:37.725584Z","shell.execute_reply.started":"2024-05-15T06:51:36.777285Z","shell.execute_reply":"2024-05-15T06:51:37.724133Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d= {0: \"airplane\",1: \"automobile\",2: \"bird\",3: \"cat\",4: \"deer\",5: \"dog\",6: \"frog\",7: \"horse\",8: \"ship\",9: \"truck\"}","metadata":{"execution":{"iopub.status.busy":"2024-05-15T06:51:37.727422Z","iopub.execute_input":"2024-05-15T06:51:37.728399Z","iopub.status.idle":"2024-05-15T06:51:37.734863Z","shell.execute_reply.started":"2024-05-15T06:51:37.728343Z","shell.execute_reply":"2024-05-15T06:51:37.733649Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train,x_test=x_train/255,x_test/255","metadata":{"execution":{"iopub.status.busy":"2024-05-15T06:51:37.737906Z","iopub.execute_input":"2024-05-15T06:51:37.738474Z","iopub.status.idle":"2024-05-15T06:51:38.248574Z","shell.execute_reply.started":"2024-05-15T06:51:37.738443Z","shell.execute_reply":"2024-05-15T06:51:38.247385Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train=y_train.reshape(50000,)","metadata":{"execution":{"iopub.status.busy":"2024-05-15T06:51:38.249860Z","iopub.execute_input":"2024-05-15T06:51:38.250215Z","iopub.status.idle":"2024-05-15T06:51:38.255637Z","shell.execute_reply.started":"2024-05-15T06:51:38.250185Z","shell.execute_reply":"2024-05-15T06:51:38.254357Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model=keras.Sequential(\n [\n     keras.layers.Conv2D(filters=32,kernel_size=(3,3),padding='same',activation='relu',input_shape=(32,32,3)),\n     keras.layers.MaxPooling2D((2,2)),\n     keras.layers.Conv2D(filters=32,kernel_size=(3,3),padding='same',activation='relu',input_shape=(32,32,3)),\n     keras.layers.MaxPooling2D((2,2)),\n     keras.layers.Flatten(),\n     keras.layers.Dense(40,activation='relu'),\n     keras.layers.Dense(30,activation='relu'),\n     keras.layers.Dense(10,activation='softmax')\n     \n ])","metadata":{"execution":{"iopub.status.busy":"2024-05-15T06:51:38.257194Z","iopub.execute_input":"2024-05-15T06:51:38.257599Z","iopub.status.idle":"2024-05-15T06:51:38.316273Z","shell.execute_reply.started":"2024-05-15T06:51:38.257568Z","shell.execute_reply":"2024-05-15T06:51:38.314873Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.compile(\noptimizer=\"adam\",\nloss='sparse_categorical_crossentropy',\nmetrics=[\"accuracy\"]\n)","metadata":{"execution":{"iopub.status.busy":"2024-05-15T06:51:38.318194Z","iopub.execute_input":"2024-05-15T06:51:38.318573Z","iopub.status.idle":"2024-05-15T06:51:38.328607Z","shell.execute_reply.started":"2024-05-15T06:51:38.318541Z","shell.execute_reply":"2024-05-15T06:51:38.327518Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.fit(x_train,y_train,epochs=10)","metadata":{"execution":{"iopub.status.busy":"2024-05-15T06:51:38.330224Z","iopub.execute_input":"2024-05-15T06:51:38.330601Z","iopub.status.idle":"2024-05-15T06:57:34.445560Z","shell.execute_reply.started":"2024-05-15T06:51:38.330571Z","shell.execute_reply":"2024-05-15T06:57:34.444605Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred=model.predict(x_test)\noutput=[np.argmax(i) for i in pred]","metadata":{"execution":{"iopub.status.busy":"2024-05-15T07:07:12.819155Z","iopub.execute_input":"2024-05-15T07:07:12.819688Z","iopub.status.idle":"2024-05-15T07:07:15.793825Z","shell.execute_reply.started":"2024-05-15T07:07:12.819649Z","shell.execute_reply":"2024-05-15T07:07:15.792687Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submissions=pd.DataFrame({\"id\": list(range(1,len(output)+1)),\n                         \"label\": output})\nsubmissions.to_csv(\"output-cifar10.csv\", index=False, header=True)","metadata":{"execution":{"iopub.status.busy":"2024-05-15T07:09:16.015356Z","iopub.execute_input":"2024-05-15T07:09:16.015828Z","iopub.status.idle":"2024-05-15T07:09:16.082904Z","shell.execute_reply.started":"2024-05-15T07:09:16.015772Z","shell.execute_reply":"2024-05-15T07:09:16.081106Z"},"trusted":true},"execution_count":null,"outputs":[]}]}