{"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"}],"dockerImageVersionId":30698,"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)\nimport tensorflow as tf\nfrom tensorflow.keras import datasets,layers,models\nimport matplotlib.pyplot as plt\n\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-06T17:33:05.859152Z","iopub.execute_input":"2024-05-06T17:33:05.859633Z","iopub.status.idle":"2024-05-06T17:33:05.872072Z","shell.execute_reply.started":"2024-05-06T17:33:05.859570Z","shell.execute_reply":"2024-05-06T17:33:05.870665Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"(xtrain,ytrain),(xtest,ytest)=datasets.cifar10.load_data()","metadata":{"execution":{"iopub.status.busy":"2024-05-06T17:33:06.285131Z","iopub.execute_input":"2024-05-06T17:33:06.285669Z","iopub.status.idle":"2024-05-06T17:33:07.384360Z","shell.execute_reply.started":"2024-05-06T17:33:06.285626Z","shell.execute_reply":"2024-05-06T17:33:07.382978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"xtrain.shape","metadata":{"execution":{"iopub.status.busy":"2024-05-06T17:33:07.386947Z","iopub.execute_input":"2024-05-06T17:33:07.387317Z","iopub.status.idle":"2024-05-06T17:33:07.395400Z","shell.execute_reply.started":"2024-05-06T17:33:07.387288Z","shell.execute_reply":"2024-05-06T17:33:07.393993Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ytrain[:3]","metadata":{"execution":{"iopub.status.busy":"2024-05-06T17:33:07.396734Z","iopub.execute_input":"2024-05-06T17:33:07.397076Z","iopub.status.idle":"2024-05-06T17:33:07.409130Z","shell.execute_reply.started":"2024-05-06T17:33:07.397048Z","shell.execute_reply":"2024-05-06T17:33:07.407744Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"siniflar=[\"plane\",\"car\",\"bird\",\"cat\",\"deer\",\"dog\",\"frog\",\"truck\",\"ship\"]","metadata":{"execution":{"iopub.status.busy":"2024-05-06T17:33:08.389026Z","iopub.execute_input":"2024-05-06T17:33:08.389430Z","iopub.status.idle":"2024-05-06T17:33:08.396737Z","shell.execute_reply.started":"2024-05-06T17:33:08.389401Z","shell.execute_reply":"2024-05-06T17:33:08.395013Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ytest=ytest.reshape(-1,)","metadata":{"execution":{"iopub.status.busy":"2024-05-06T17:33:09.012992Z","iopub.execute_input":"2024-05-06T17:33:09.013427Z","iopub.status.idle":"2024-05-06T17:33:09.019030Z","shell.execute_reply.started":"2024-05-06T17:33:09.013394Z","shell.execute_reply":"2024-05-06T17:33:09.017678Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def example(x,y,index):\n    plt.figure(figsize=(15,2))\n    plt.imshow(x[index])\n    plt.xlabel(siniflar[y[index]])\n    ","metadata":{"execution":{"iopub.status.busy":"2024-05-06T17:33:09.343041Z","iopub.execute_input":"2024-05-06T17:33:09.343507Z","iopub.status.idle":"2024-05-06T17:33:09.350793Z","shell.execute_reply.started":"2024-05-06T17:33:09.343472Z","shell.execute_reply":"2024-05-06T17:33:09.349077Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"example(xtest,ytest,1)","metadata":{"execution":{"iopub.status.busy":"2024-05-06T17:33:09.902820Z","iopub.execute_input":"2024-05-06T17:33:09.903243Z","iopub.status.idle":"2024-05-06T17:33:10.061250Z","shell.execute_reply.started":"2024-05-06T17:33:09.903213Z","shell.execute_reply":"2024-05-06T17:33:10.059851Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"xtrain=xtrain/255\nxtest=xtest/255","metadata":{"execution":{"iopub.status.busy":"2024-05-06T17:33:10.925738Z","iopub.execute_input":"2024-05-06T17:33:10.926222Z","iopub.status.idle":"2024-05-06T17:33:11.467430Z","shell.execute_reply.started":"2024-05-06T17:33:10.926177Z","shell.execute_reply":"2024-05-06T17:33:11.465990Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model=models.Sequential([\n    layers.Conv2D(filters=32,kernel_size=(3,3),activation=\"relu\",input_shape=(32,32,3)),\n    layers.MaxPooling2D(2,2),\n    \n    layers.Conv2D(filters=64,kernel_size=(3,3),activation=\"relu\"),\n    layers.MaxPooling2D(2,2),\n    \n    layers.Flatten(),\n    layers.Dense(64,activation=\"relu\"),\n    layers.Dense(10,activation=\"softmax\")\n])","metadata":{"execution":{"iopub.status.busy":"2024-05-06T17:33:12.309301Z","iopub.execute_input":"2024-05-06T17:33:12.309951Z","iopub.status.idle":"2024-05-06T17:33:12.392260Z","shell.execute_reply.started":"2024-05-06T17:33:12.309908Z","shell.execute_reply":"2024-05-06T17:33:12.391173Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.compile(optimizer=\"adam\",\n             loss=\"sparse_categorical_crossentropy\",\n             metrics=[\"accuracy\"])","metadata":{"execution":{"iopub.status.busy":"2024-05-06T17:33:16.504121Z","iopub.execute_input":"2024-05-06T17:33:16.504566Z","iopub.status.idle":"2024-05-06T17:33:16.519767Z","shell.execute_reply.started":"2024-05-06T17:33:16.504526Z","shell.execute_reply":"2024-05-06T17:33:16.517697Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.fit(xtrain,ytrain,epochs=15)","metadata":{"execution":{"iopub.status.busy":"2024-05-06T16:46:56.988035Z","iopub.execute_input":"2024-05-06T16:46:56.988675Z","iopub.status.idle":"2024-05-06T16:54:45.403427Z","shell.execute_reply.started":"2024-05-06T16:46:56.988640Z","shell.execute_reply":"2024-05-06T16:54:45.401992Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.evaluate(xtest,ytest)","metadata":{"execution":{"iopub.status.busy":"2024-05-06T17:33:20.024053Z","iopub.execute_input":"2024-05-06T17:33:20.024810Z","iopub.status.idle":"2024-05-06T17:33:23.448849Z","shell.execute_reply.started":"2024-05-06T17:33:20.024763Z","shell.execute_reply":"2024-05-06T17:33:23.447919Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ypred=model.predict(xtest)\nypred[:3]","metadata":{"execution":{"iopub.status.busy":"2024-05-06T17:33:23.450787Z","iopub.execute_input":"2024-05-06T17:33:23.451177Z","iopub.status.idle":"2024-05-06T17:33:28.965505Z","shell.execute_reply.started":"2024-05-06T17:33:23.451145Z","shell.execute_reply":"2024-05-06T17:33:28.964576Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ypred1=[np.argmax(element)for element in ypred]\nypred1[:3]","metadata":{"execution":{"iopub.status.busy":"2024-05-06T17:33:28.966946Z","iopub.execute_input":"2024-05-06T17:33:28.967558Z","iopub.status.idle":"2024-05-06T17:33:29.000358Z","shell.execute_reply.started":"2024-05-06T17:33:28.967525Z","shell.execute_reply":"2024-05-06T17:33:28.999152Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ytest[:3]","metadata":{"execution":{"iopub.status.busy":"2024-05-06T17:33:29.002751Z","iopub.execute_input":"2024-05-06T17:33:29.003120Z","iopub.status.idle":"2024-05-06T17:33:29.010739Z","shell.execute_reply.started":"2024-05-06T17:33:29.003088Z","shell.execute_reply":"2024-05-06T17:33:29.009405Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"example(xtest,ytest,0)","metadata":{"execution":{"iopub.status.busy":"2024-05-06T17:33:29.012193Z","iopub.execute_input":"2024-05-06T17:33:29.013392Z","iopub.status.idle":"2024-05-06T17:33:29.211873Z","shell.execute_reply.started":"2024-05-06T17:33:29.013355Z","shell.execute_reply":"2024-05-06T17:33:29.210488Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"example(xtest,ytest,1)","metadata":{"execution":{"iopub.status.busy":"2024-05-06T17:33:29.213166Z","iopub.execute_input":"2024-05-06T17:33:29.213504Z","iopub.status.idle":"2024-05-06T17:33:29.415982Z","shell.execute_reply.started":"2024-05-06T17:33:29.213475Z","shell.execute_reply":"2024-05-06T17:33:29.414723Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"example(xtest,ytest,4)","metadata":{"execution":{"iopub.status.busy":"2024-05-06T17:33:29.417779Z","iopub.execute_input":"2024-05-06T17:33:29.418329Z","iopub.status.idle":"2024-05-06T17:33:29.630352Z","shell.execute_reply.started":"2024-05-06T17:33:29.418281Z","shell.execute_reply":"2024-05-06T17:33:29.629040Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}