{ "cells": [ { "cell_type": "code", "execution_count": 17, "id": "operational-tablet", "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "from keras.datasets import cifar10\n", "import pandas as pd\n", "import numpy as np\n", "from tensorflow.keras.utils import to_categorical\n", "from tensorflow.keras.models import Model, Sequential\n", "from tensorflow.keras.layers import Conv2D,MaxPooling2D,Flatten,Dense\n", "from tensorflow.keras.optimizers import SGD\n", "from sklearn.model_selection import train_test_split" ] }, { "cell_type": "code", "execution_count": 18, "id": "stunning-sussex", "metadata": {}, "outputs": [], "source": [ "(x_train, y_train), (x_test, y_test)= cifar10.load_data()" ] }, { "cell_type": "code", "execution_count": 19, "id": "drawn-voluntary", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(50000, 32, 32, 3)" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x_train.shape" ] }, { "cell_type": "code", "execution_count": 20, "id": "hundred-healthcare", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(50000, 1)" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "y_train.shape" ] }, { "cell_type": "code", "execution_count": 21, "id": "built-gazette", "metadata": {}, "outputs": [], "source": [ "xtrain_df=pd.DataFrame(x_train.reshape((len(x_train), np.prod(x_train.shape[1:]))))\n", "ytrain_df=pd.DataFrame(y_train, columns=[\"target\"])" ] }, { "cell_type": "code", "execution_count": 22, "id": "combined-classroom", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | 0 | \n", "1 | \n", "2 | \n", "3 | \n", "4 | \n", "5 | \n", "6 | \n", "7 | \n", "8 | \n", "9 | \n", "... | \n", "3063 | \n", "3064 | \n", "3065 | \n", "3066 | \n", "3067 | \n", "3068 | \n", "3069 | \n", "3070 | \n", "3071 | \n", "target | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "59 | \n", "62 | \n", "63 | \n", "43 | \n", "46 | \n", "45 | \n", "50 | \n", "48 | \n", "43 | \n", "68 | \n", "... | \n", "216 | \n", "184 | \n", "140 | \n", "151 | \n", "118 | \n", "84 | \n", "123 | \n", "92 | \n", "72 | \n", "6 | \n", "
1 | \n", "154 | \n", "177 | \n", "187 | \n", "126 | \n", "137 | \n", "136 | \n", "105 | \n", "104 | \n", "95 | \n", "102 | \n", "... | \n", "143 | \n", "133 | \n", "139 | \n", "143 | \n", "134 | \n", "142 | \n", "143 | \n", "133 | \n", "144 | \n", "9 | \n", "
2 | \n", "255 | \n", "255 | \n", "255 | \n", "253 | \n", "253 | \n", "253 | \n", "253 | \n", "253 | \n", "253 | \n", "253 | \n", "... | \n", "78 | \n", "85 | \n", "83 | \n", "79 | \n", "85 | \n", "83 | \n", "80 | \n", "86 | \n", "84 | \n", "9 | \n", "
3 | \n", "28 | \n", "25 | \n", "10 | \n", "37 | \n", "34 | \n", "19 | \n", "38 | \n", "35 | \n", "20 | \n", "42 | \n", "... | \n", "54 | \n", "47 | \n", "28 | \n", "63 | \n", "56 | \n", "37 | \n", "72 | \n", "65 | \n", "46 | \n", "4 | \n", "
4 | \n", "170 | \n", "180 | \n", "198 | \n", "168 | \n", "178 | \n", "196 | \n", "177 | \n", "185 | \n", "203 | \n", "183 | \n", "... | \n", "75 | \n", "79 | \n", "82 | \n", "71 | \n", "75 | \n", "78 | \n", "73 | \n", "77 | \n", "80 | \n", "1 | \n", "
5 rows × 3073 columns
\n", "\n", " | 0 | \n", "1 | \n", "2 | \n", "3 | \n", "4 | \n", "5 | \n", "6 | \n", "7 | \n", "8 | \n", "9 | \n", "... | \n", "class1 | \n", "class2 | \n", "class3 | \n", "class4 | \n", "class5 | \n", "class6 | \n", "class7 | \n", "class8 | \n", "class9 | \n", "class10 | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "59 | \n", "62 | \n", "63 | \n", "43 | \n", "46 | \n", "45 | \n", "50 | \n", "48 | \n", "43 | \n", "68 | \n", "... | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "
1 | \n", "154 | \n", "177 | \n", "187 | \n", "126 | \n", "137 | \n", "136 | \n", "105 | \n", "104 | \n", "95 | \n", "102 | \n", "... | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.0 | \n", "
2 | \n", "255 | \n", "255 | \n", "255 | \n", "253 | \n", "253 | \n", "253 | \n", "253 | \n", "253 | \n", "253 | \n", "253 | \n", "... | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.0 | \n", "
3 | \n", "28 | \n", "25 | \n", "10 | \n", "37 | \n", "34 | \n", "19 | \n", "38 | \n", "35 | \n", "20 | \n", "42 | \n", "... | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "1.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "
4 | \n", "170 | \n", "180 | \n", "198 | \n", "168 | \n", "178 | \n", "196 | \n", "177 | \n", "185 | \n", "203 | \n", "183 | \n", "... | \n", "0.0 | \n", "1.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "
5 rows × 3082 columns
\n", "