{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.13.15","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[],"dockerImageVersionId":28755,"isInternetEnabled":false,"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)\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\n\n# Use the kagglehub client library to attach Kaggle resources like competitions, datasets, and models to your session\n# Learn more about kagglehub: https://github.com/Kaggle/kagglehub/blob/main/README.md\n\nimport kagglehub\n# kagglehub.dataset_download('<owner>/<dataset-slug>')","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:49:29.510386Z","iopub.execute_input":"2026-10-09T08:49:29.510901Z","iopub.status.idle":"2026-10-09T08:49:30.789603Z","shell.execute_reply.started":"2026-10-09T08:49:29.510871Z","shell.execute_reply":"2026-10-09T08:49:30.788907Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\ntrain_labels = pd.read_csv('/kaggle/input/competitions/cifar-10/trainLabels.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:49:30.79083Z","iopub.execute_input":"2026-10-09T08:49:30.791304Z","iopub.status.idle":"2026-10-09T08:49:30.868161Z","shell.execute_reply.started":"2026-10-09T08:49:30.791278Z","shell.execute_reply":"2026-10-09T08:49:30.867537Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_labels","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:49:30.869011Z","iopub.execute_input":"2026-10-09T08:49:30.869413Z","iopub.status.idle":"2026-10-09T08:49:30.903687Z","shell.execute_reply.started":"2026-10-09T08:49:30.869388Z","shell.execute_reply":"2026-10-09T08:49:30.903108Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\n\nprint(os.listdir(\"/kaggle/input/competitions/cifar-10\"))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:49:30.905435Z","iopub.execute_input":"2026-10-09T08:49:30.9057Z","iopub.status.idle":"2026-10-09T08:49:30.910123Z","shell.execute_reply.started":"2026-10-09T08:49:30.905681Z","shell.execute_reply":"2026-10-09T08:49:30.909143Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip install -q py7zr","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:49:30.911111Z","iopub.execute_input":"2026-10-09T08:49:30.911437Z","iopub.status.idle":"2026-10-09T08:49:37.010934Z","shell.execute_reply.started":"2026-10-09T08:49:30.911418Z","shell.execute_reply":"2026-10-09T08:49:37.01019Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\n\nfor root, dirs, files in os.walk(\"/kaggle/input\"):\n    for file in files:\n        if file.endswith(\".7z\"):\n            print(os.path.join(root, file))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:49:37.0124Z","iopub.execute_input":"2026-10-09T08:49:37.012976Z","iopub.status.idle":"2026-10-09T08:49:37.019203Z","shell.execute_reply.started":"2026-10-09T08:49:37.012948Z","shell.execute_reply":"2026-10-09T08:49:37.018406Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import py7zr\nimport os\n\narchive_path =\"/kaggle/input/competitions/cifar-10/train.7z\"\nextract_path = \"/kaggle/working/train\"\n\nos.makedirs(extract_path, exist_ok=True)\n\nwith py7zr.SevenZipFile(archive_path, mode=\"r\") as archive:\n    archive.extractall(path=extract_path)\n\nprint(os.listdir(extract_path)[:10])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:49:37.02023Z","iopub.execute_input":"2026-10-09T08:49:37.020603Z","iopub.status.idle":"2026-10-09T08:50:10.721545Z","shell.execute_reply.started":"2026-10-09T08:49:37.020568Z","shell.execute_reply":"2026-10-09T08:50:10.720583Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"image_paths = []\n\nfor root, dirs, files in os.walk(extract_path):\n    for file in files:\n        if file.endswith(\".png\"):\n            image_paths.append(os.path.join(root, file))\n\nprint(\"Number of images:\", len(image_paths))\nprint(image_paths[:5])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:50:10.722777Z","iopub.execute_input":"2026-10-09T08:50:10.723166Z","iopub.status.idle":"2026-10-09T08:50:10.792694Z","shell.execute_reply.started":"2026-10-09T08:50:10.723142Z","shell.execute_reply":"2026-10-09T08:50:10.792102Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\nimport os\n\ndf = pd.DataFrame({\n    \"image_path\": image_paths\n})\n\ndf[\"id\"] = df[\"image_path\"].apply(\n    lambda path: os.path.splitext(os.path.basename(path))[0]\n)\n\nprint(df.head())\nprint(\"Total images:\", len(df))\ndf['id'] = df['id'].astype(int)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:50:10.793665Z","iopub.execute_input":"2026-10-09T08:50:10.793945Z","iopub.status.idle":"2026-10-09T08:50:10.870101Z","shell.execute_reply.started":"2026-10-09T08:50:10.793916Z","shell.execute_reply":"2026-10-09T08:50:10.869312Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df = pd.merge(df, train_labels, on='id', how='inner')\ndf.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:50:10.872818Z","iopub.execute_input":"2026-10-09T08:50:10.87317Z","iopub.status.idle":"2026-10-09T08:50:10.914611Z","shell.execute_reply.started":"2026-10-09T08:50:10.873149Z","shell.execute_reply":"2026-10-09T08:50:10.914116Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder\n\nle = LabelEncoder()\n\ndf[\"label\"] = le.fit_transform(df[\"label\"])\n\nprint(df.head())\nprint(le.classes_)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:50:10.915748Z","iopub.execute_input":"2026-10-09T08:50:10.916115Z","iopub.status.idle":"2026-10-09T08:50:11.59712Z","shell.execute_reply.started":"2026-10-09T08:50:10.916083Z","shell.execute_reply":"2026-10-09T08:50:11.596103Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"levels_encoding = le.inverse_transform(([0,1,2,3,4,5,6,7,8,9]))\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:50:11.598269Z","iopub.execute_input":"2026-10-09T08:50:11.598755Z","iopub.status.idle":"2026-10-09T08:50:11.606208Z","shell.execute_reply.started":"2026-10-09T08:50:11.598721Z","shell.execute_reply":"2026-10-09T08:50:11.605269Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\n\n# Split into 80% train and 20% test\ntrain_df, val_df = train_test_split(df, test_size=0.2, random_state=42)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:50:11.60741Z","iopub.execute_input":"2026-10-09T08:50:11.607742Z","iopub.status.idle":"2026-10-09T08:50:11.74113Z","shell.execute_reply.started":"2026-10-09T08:50:11.607718Z","shell.execute_reply":"2026-10-09T08:50:11.740107Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(train_df.shape)\nprint(train_df.columns)\nprint(train_df.head())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:36:30.090792Z","iopub.execute_input":"2026-10-09T09:36:30.091114Z","iopub.status.idle":"2026-10-09T09:36:30.097865Z","shell.execute_reply.started":"2026-10-09T09:36:30.091091Z","shell.execute_reply":"2026-10-09T09:36:30.096917Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import torch\nfrom torch.utils.data import Dataset , DataLoader\nfrom PIL import Image\n\nclass CIFAR10Dataset(Dataset):\n\n    def __init__(self, df, transform=None):\n        self.df = df.reset_index(drop=True)\n        self.transform = transform\n\n    def __len__(self):\n        return len(self.df)\n\n    def __getitem__(self, idx):\n        image_path = self.df.loc[idx, \"image_path\"]\n        label = self.df.loc[idx, \"label\"]\n    \n        image = Image.open(image_path).convert(\"RGB\")\n    \n        if self.transform:\n            image = self.transform(image)\n    \n        return image, label","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:50:11.742438Z","iopub.execute_input":"2026-10-09T08:50:11.743089Z","iopub.status.idle":"2026-10-09T08:50:18.529745Z","shell.execute_reply.started":"2026-10-09T08:50:11.743033Z","shell.execute_reply":"2026-10-09T08:50:18.529104Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from torchvision import transforms\n\ntest_transform = transforms.Compose([\n    transforms.ToTensor()\n])\n\ntrain_transform = transforms.Compose([\n    transforms.RandomCrop(32, padding=4),\n    transforms.RandomHorizontalFlip(),\n    transforms.ToTensor()\n])\n\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:50:18.531101Z","iopub.execute_input":"2026-10-09T08:50:18.531928Z","iopub.status.idle":"2026-10-09T08:50:22.505224Z","shell.execute_reply.started":"2026-10-09T08:50:18.531876Z","shell.execute_reply":"2026-10-09T08:50:22.504233Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_dataset = CIFAR10Dataset(train_df , train_transform)\nval_dataset = CIFAR10Dataset(val_df , test_transform)\n\ntrain_loader = DataLoader(train_dataset , batch_size = 128 , shuffle = True)\nval_loader = DataLoader(val_dataset , batch_size = 128 , shuffle = False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:50:22.506461Z","iopub.execute_input":"2026-10-09T08:50:22.507099Z","iopub.status.idle":"2026-10-09T08:50:22.523343Z","shell.execute_reply.started":"2026-10-09T08:50:22.507032Z","shell.execute_reply":"2026-10-09T08:50:22.522452Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(df.shape)\nprint(df.columns)\nprint(df.head())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:35:44.462912Z","iopub.execute_input":"2026-10-09T09:35:44.463664Z","iopub.status.idle":"2026-10-09T09:35:44.470004Z","shell.execute_reply.started":"2026-10-09T09:35:44.463636Z","shell.execute_reply":"2026-10-09T09:35:44.469178Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"full_dataset = CIFAR10Dataset(df , train_transform)\nfull_loader = DataLoader(full_dataset , batch_size = 128 , shuffle = True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:27:24.014468Z","iopub.execute_input":"2026-10-09T09:27:24.014775Z","iopub.status.idle":"2026-10-09T09:27:24.021859Z","shell.execute_reply.started":"2026-10-09T09:27:24.014753Z","shell.execute_reply":"2026-10-09T09:27:24.021123Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"batch = next(iter(full_loader))\n\nprint(batch.shape)\nprint(batch.dtype)\nfull_dataset[0].shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:33:35.235358Z","iopub.execute_input":"2026-10-09T09:33:35.235974Z","iopub.status.idle":"2026-10-09T09:33:35.307325Z","shell.execute_reply.started":"2026-10-09T09:33:35.235948Z","shell.execute_reply":"2026-10-09T09:33:35.306528Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"\nimport torch\nimport torch.nn as nn\n\nclass CNN(nn.Module):\n    def __init__(self):\n        super().__init__()\n\n        self.cn = nn.Sequential(\n            nn.Conv2d(3, 64, kernel_size=3, padding=\"same\"),\n            nn.ReLU(),\n            nn.BatchNorm2d(64),\n            nn.MaxPool2d(kernel_size=2, stride=2),\n\n            nn.Conv2d(64, 128, kernel_size=3, padding=\"same\"),\n            nn.ReLU(),\n            nn.BatchNorm2d(128),\n            nn.MaxPool2d(kernel_size=2, stride=2),\n\n            nn.Conv2d(128, 256, kernel_size=3, padding=\"same\"),\n            nn.ReLU(),\n            nn.BatchNorm2d(256),\n            nn.MaxPool2d(kernel_size=2, stride=2)\n        )\n\n        self.fc = nn.Sequential(\n            nn.Flatten(),\n            nn.Linear(4 * 4 * 256, 256),\n            nn.ReLU(),\n            nn.Dropout(0.4),\n\n            nn.Linear(256, 128),\n            nn.ReLU(),\n            nn.Dropout(0.4),\n\n            nn.Linear(128, 10)\n        )\n\n    def forward(self, x):\n        x = self.cn(x)\n        x = self.fc(x)\n        return x\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:23:25.429599Z","iopub.execute_input":"2026-10-09T09:23:25.430207Z","iopub.status.idle":"2026-10-09T09:23:25.43701Z","shell.execute_reply.started":"2026-10-09T09:23:25.430179Z","shell.execute_reply":"2026-10-09T09:23:25.436278Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import torch\ndevice = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\nmodel = CNN().to(device)\nloss_fn = nn.CrossEntropyLoss()\noptimizer = torch.optim.Adam(model.parameters(), lr=0.001)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:52:01.574018Z","iopub.execute_input":"2026-10-09T08:52:01.574338Z","iopub.status.idle":"2026-10-09T08:52:02.850889Z","shell.execute_reply.started":"2026-10-09T08:52:01.574315Z","shell.execute_reply":"2026-10-09T08:52:02.849896Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for epoch in range(50):\n    model.train()\n    running_loss = 0.0\n    count = 0\n    for data, targets in train_loader:\n        data, targets = data.to(device), targets.to(device)\n        optimizer.zero_grad()\n        loss = loss_fn(model(data), targets)\n        loss.backward() # Added backpropagation step to compute gradients\n        optimizer.step()\n        running_loss += loss.item() * data.size(0)\n        count +=  data.size(0)\n    \n    \n    print(f\"Epoch {epoch + 1}, Loss: {running_loss / len(train_loader.dataset):.4f}\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:52:02.852229Z","iopub.execute_input":"2026-10-09T08:52:02.852725Z","iopub.status.idle":"2026-10-09T09:12:22.121912Z","shell.execute_reply.started":"2026-10-09T08:52:02.852702Z","shell.execute_reply":"2026-10-09T09:12:22.121121Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.eval()\ncorrect = 0\ntotal = 0\n\nwith torch.no_grad():\n  for data, targets in val_loader:\n    data, targets = data.to(device), targets.to(device)\n    outputs = model(data)\n    _, predicted = torch.max(outputs,dim=1)\n    correct += (predicted == targets).sum().item()\n    total += targets.size(0)\n    \naccuracy = (correct / total) * 100\nprint(f\"Test Accuracy: {accuracy:.2f}%\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:12:22.123146Z","iopub.execute_input":"2026-10-09T09:12:22.123374Z","iopub.status.idle":"2026-10-09T09:12:26.330969Z","shell.execute_reply.started":"2026-10-09T09:12:22.123355Z","shell.execute_reply":"2026-10-09T09:12:26.330279Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.eval()\ncorrect = 0\ntotal = 0\n\nwith torch.no_grad():\n  for data, targets in train_loader:\n    data, targets = data.to(device), targets.to(device)\n    outputs = model(data)\n    _, predicted = torch.max(outputs,dim=1)\n    correct += (predicted == targets).sum().item()\n    total += targets.size(0)\n    \naccuracy = (correct / total) * 100\nprint(f\"Test Accuracy: {accuracy:.2f}%\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:12:26.332655Z","iopub.execute_input":"2026-10-09T09:12:26.333003Z","iopub.status.idle":"2026-10-09T09:12:47.521856Z","shell.execute_reply.started":"2026-10-09T09:12:26.332982Z","shell.execute_reply":"2026-10-09T09:12:47.521137Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for epoch in range(10):\n    model.train()\n    running_loss = 0.0\n    count = 0\n    for data, targets in full_loader:\n        data, targets = data.to(device), targets.to(device)\n        optimizer.zero_grad()\n        loss = loss_fn(model(data), targets)\n        loss.backward() # Added backpropagation step to compute gradients\n        optimizer.step()\n        running_loss += loss.item() * data.size(0)\n        count +=  data.size(0)\n    \n    \n    print(f\"Epoch {epoch + 1}, Loss: {running_loss / len(train_loader.dataset):.4f}\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:30:20.894624Z","iopub.execute_input":"2026-10-09T09:30:20.895119Z","iopub.status.idle":"2026-10-09T09:30:20.971452Z","shell.execute_reply.started":"2026-10-09T09:30:20.895088Z","shell.execute_reply":"2026-10-09T09:30:20.970539Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import py7zr\nimport os\n\narchive_path =\"/kaggle/input/competitions/cifar-10/test.7z\"\nextract_path = \"/kaggle/working/test\"\n\nos.makedirs(extract_path, exist_ok=True)\n\nwith py7zr.SevenZipFile(archive_path, mode=\"r\") as archive:\n    archive.extractall(path=extract_path)\n\nprint(os.listdir(extract_path)[:10])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:12:47.522914Z","iopub.execute_input":"2026-10-09T09:12:47.523226Z","iopub.status.idle":"2026-10-09T09:16:12.216414Z","shell.execute_reply.started":"2026-10-09T09:12:47.523204Z","shell.execute_reply":"2026-10-09T09:16:12.215137Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"image_paths = []\n\nfor root, dirs, files in os.walk(extract_path):\n    for file in files:\n        if file.endswith(\".png\"):\n            image_paths.append(os.path.join(root, file))\n\nprint(\"Number of images:\", len(image_paths))\nprint(image_paths[:5])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:16:12.217734Z","iopub.execute_input":"2026-10-09T09:16:12.218826Z","iopub.status.idle":"2026-10-09T09:16:12.630338Z","shell.execute_reply.started":"2026-10-09T09:16:12.218778Z","shell.execute_reply":"2026-10-09T09:16:12.629627Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\nimport os\n\ntest_df = pd.DataFrame({\n    \"image_path\": image_paths\n})\n\ntest_df[\"id\"] = test_df[\"image_path\"].apply(\n    lambda path: os.path.splitext(os.path.basename(path))[0]\n)\n\ntest_df[\"id\"] = test_df[\"id\"].astype(int)\n\ntest_df = test_df.sort_values(\"id\").reset_index(drop=True)\nprint(test_df.head())\nprint(\"Total images:\", len(test_df))\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:16:12.631395Z","iopub.execute_input":"2026-10-09T09:16:12.631746Z","iopub.status.idle":"2026-10-09T09:16:13.089386Z","shell.execute_reply.started":"2026-10-09T09:16:12.631723Z","shell.execute_reply":"2026-10-09T09:16:13.088609Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from PIL import Image\n\nclass CIFAR10Dataset(Dataset):\n\n    def __init__(self, df, transform=None):\n        self.df = df.reset_index(drop=True)\n        self.transform = transform\n\n    def __len__(self):\n        return len(self.df)\n\n    def __getitem__(self, idx):\n        image_path = self.df.loc[idx, \"image_path\"]\n    \n        image = Image.open(image_path).convert(\"RGB\")\n    \n        if self.transform:\n            image = self.transform(image)\n    \n        return image","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:16:13.090487Z","iopub.execute_input":"2026-10-09T09:16:13.090783Z","iopub.status.idle":"2026-10-09T09:16:13.096658Z","shell.execute_reply.started":"2026-10-09T09:16:13.09076Z","shell.execute_reply":"2026-10-09T09:16:13.095895Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"\ntest_dataset = CIFAR10Dataset(test_df, transform=test_transform)\n\ntest_loader = DataLoader(\n    test_dataset,\n    batch_size=128,\n    shuffle=False\n)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:16:13.097782Z","iopub.execute_input":"2026-10-09T09:16:13.098199Z","iopub.status.idle":"2026-10-09T09:16:13.118657Z","shell.execute_reply.started":"2026-10-09T09:16:13.098177Z","shell.execute_reply":"2026-10-09T09:16:13.117966Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_dataset[0]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:16:13.121473Z","iopub.execute_input":"2026-10-09T09:16:13.12193Z","iopub.status.idle":"2026-10-09T09:16:13.180961Z","shell.execute_reply.started":"2026-10-09T09:16:13.121908Z","shell.execute_reply":"2026-10-09T09:16:13.180355Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.eval()\ntest_pred = []\n\nwith torch.no_grad():\n    for data in test_loader:\n        data = data.to(device)\n\n        outputs = model(data)\n        _, predicted = torch.max(outputs, dim=1)\n\n        test_pred.extend(predicted.cpu().tolist())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:16:13.181857Z","iopub.execute_input":"2026-10-09T09:16:13.182222Z","iopub.status.idle":"2026-10-09T09:18:10.622923Z","shell.execute_reply.started":"2026-10-09T09:16:13.182181Z","shell.execute_reply":"2026-10-09T09:18:10.622197Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"len(test_pred)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:18:10.623992Z","iopub.execute_input":"2026-10-09T09:18:10.624409Z","iopub.status.idle":"2026-10-09T09:18:10.630879Z","shell.execute_reply.started":"2026-10-09T09:18:10.624362Z","shell.execute_reply":"2026-10-09T09:18:10.630002Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submission = pd.read_csv('/kaggle/input/competitions/cifar-10/sampleSubmission.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:18:10.632373Z","iopub.execute_input":"2026-10-09T09:18:10.632826Z","iopub.status.idle":"2026-10-09T09:18:10.829683Z","shell.execute_reply.started":"2026-10-09T09:18:10.6328Z","shell.execute_reply":"2026-10-09T09:18:10.828881Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submission.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:18:10.830906Z","iopub.execute_input":"2026-10-09T09:18:10.831533Z","iopub.status.idle":"2026-10-09T09:18:10.840661Z","shell.execute_reply.started":"2026-10-09T09:18:10.8315Z","shell.execute_reply":"2026-10-09T09:18:10.839872Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_pred_level =[]\nfor i in test_pred:\n    test_pred_level.append(levels_encoding[i])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:18:10.841768Z","iopub.execute_input":"2026-10-09T09:18:10.842121Z","iopub.status.idle":"2026-10-09T09:18:10.898257Z","shell.execute_reply.started":"2026-10-09T09:18:10.84209Z","shell.execute_reply":"2026-10-09T09:18:10.897484Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_pred_level[:5]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:18:10.899376Z","iopub.execute_input":"2026-10-09T09:18:10.900021Z","iopub.status.idle":"2026-10-09T09:18:10.906224Z","shell.execute_reply.started":"2026-10-09T09:18:10.899963Z","shell.execute_reply":"2026-10-09T09:18:10.905309Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submission['label'] = test_pred_level","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:18:10.907549Z","iopub.execute_input":"2026-10-09T09:18:10.907933Z","iopub.status.idle":"2026-10-09T09:18:10.957098Z","shell.execute_reply.started":"2026-10-09T09:18:10.907909Z","shell.execute_reply":"2026-10-09T09:18:10.956429Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submission.to_csv(\n    \"/kaggle/working/CIFAR_submission.csv\",\n    index=False\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T09:18:10.95816Z","iopub.execute_input":"2026-10-09T09:18:10.958448Z","iopub.status.idle":"2026-10-09T09:18:11.217721Z","shell.execute_reply.started":"2026-10-09T09:18:10.95841Z","shell.execute_reply":"2026-10-09T09:18:11.217114Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submission","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-09T08:50:22.581861Z","iopub.status.idle":"2026-10-09T08:50:22.582294Z","shell.execute_reply.started":"2026-10-09T08:50:22.582104Z","shell.execute_reply":"2026-10-09T08:50:22.582122Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"","metadata":{}}]}