{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"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","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-04-20T04:35:11.239263Z","iopub.execute_input":"2022-04-20T04:35:11.239995Z","iopub.status.idle":"2022-04-20T04:35:11.284835Z","shell.execute_reply.started":"2022-04-20T04:35:11.239860Z","shell.execute_reply":"2022-04-20T04:35:11.283112Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install py7zr","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:35:11.287965Z","iopub.execute_input":"2022-04-20T04:35:11.292655Z","iopub.status.idle":"2022-04-20T04:35:22.432890Z","shell.execute_reply.started":"2022-04-20T04:35:11.292579Z","shell.execute_reply":"2022-04-20T04:35:22.432052Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv(\"../input/cifar-10/trainLabels.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:35:22.436235Z","iopub.execute_input":"2022-04-20T04:35:22.436471Z","iopub.status.idle":"2022-04-20T04:35:22.469403Z","shell.execute_reply.started":"2022-04-20T04:35:22.436444Z","shell.execute_reply":"2022-04-20T04:35:22.468669Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:35:22.471609Z","iopub.execute_input":"2022-04-20T04:35:22.471893Z","iopub.status.idle":"2022-04-20T04:35:22.489475Z","shell.execute_reply.started":"2022-04-20T04:35:22.471856Z","shell.execute_reply":"2022-04-20T04:35:22.488832Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:35:22.490648Z","iopub.execute_input":"2022-04-20T04:35:22.490951Z","iopub.status.idle":"2022-04-20T04:35:22.496875Z","shell.execute_reply.started":"2022-04-20T04:35:22.490915Z","shell.execute_reply":"2022-04-20T04:35:22.496190Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import py7zr\narchive = py7zr.SevenZipFile('../input/cifar-10/train.7z',mode = 'r')\narchive.extractall(path=\"../temp\")","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:35:22.498494Z","iopub.execute_input":"2022-04-20T04:35:22.498955Z","iopub.status.idle":"2022-04-20T04:36:02.820433Z","shell.execute_reply.started":"2022-04-20T04:35:22.498918Z","shell.execute_reply":"2022-04-20T04:36:02.819671Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd \"../temp\"","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:02.821592Z","iopub.execute_input":"2022-04-20T04:36:02.821836Z","iopub.status.idle":"2022-04-20T04:36:02.831278Z","shell.execute_reply.started":"2022-04-20T04:36:02.821803Z","shell.execute_reply":"2022-04-20T04:36:02.830585Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%ls","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:02.832475Z","iopub.execute_input":"2022-04-20T04:36:02.832990Z","iopub.status.idle":"2022-04-20T04:36:03.548440Z","shell.execute_reply.started":"2022-04-20T04:36:02.832955Z","shell.execute_reply":"2022-04-20T04:36:03.547514Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd train","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:03.550040Z","iopub.execute_input":"2022-04-20T04:36:03.550345Z","iopub.status.idle":"2022-04-20T04:36:03.555956Z","shell.execute_reply.started":"2022-04-20T04:36:03.550309Z","shell.execute_reply":"2022-04-20T04:36:03.555131Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n\n\n%pwd","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:03.560298Z","iopub.execute_input":"2022-04-20T04:36:03.560806Z","iopub.status.idle":"2022-04-20T04:36:03.567386Z","shell.execute_reply.started":"2022-04-20T04:36:03.560770Z","shell.execute_reply":"2022-04-20T04:36:03.566621Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport matplotlib.image as img","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:03.568590Z","iopub.execute_input":"2022-04-20T04:36:03.569324Z","iopub.status.idle":"2022-04-20T04:36:03.575060Z","shell.execute_reply.started":"2022-04-20T04:36:03.569284Z","shell.execute_reply":"2022-04-20T04:36:03.574386Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"im  = img.imread('1.png')\n\nplt.imshow(im)\nim.shape","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:03.577561Z","iopub.execute_input":"2022-04-20T04:36:03.578279Z","iopub.status.idle":"2022-04-20T04:36:03.793116Z","shell.execute_reply.started":"2022-04-20T04:36:03.578243Z","shell.execute_reply":"2022-04-20T04:36:03.792352Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classes = df['label'].unique()","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:03.794270Z","iopub.execute_input":"2022-04-20T04:36:03.795172Z","iopub.status.idle":"2022-04-20T04:36:03.809851Z","shell.execute_reply.started":"2022-04-20T04:36:03.795111Z","shell.execute_reply":"2022-04-20T04:36:03.808978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classes","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:03.811534Z","iopub.execute_input":"2022-04-20T04:36:03.812123Z","iopub.status.idle":"2022-04-20T04:36:03.818107Z","shell.execute_reply.started":"2022-04-20T04:36:03.812082Z","shell.execute_reply":"2022-04-20T04:36:03.817395Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_images_path = \"/kaggle/temp/train\"\nval_images_path = '/kaggle/temp/validation'","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:03.819787Z","iopub.execute_input":"2022-04-20T04:36:03.820335Z","iopub.status.idle":"2022-04-20T04:36:03.826629Z","shell.execute_reply.started":"2022-04-20T04:36:03.820296Z","shell.execute_reply":"2022-04-20T04:36:03.825927Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.mkdir(val_images_path)","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:03.828014Z","iopub.execute_input":"2022-04-20T04:36:03.828304Z","iopub.status.idle":"2022-04-20T04:36:03.835972Z","shell.execute_reply.started":"2022-04-20T04:36:03.828267Z","shell.execute_reply":"2022-04-20T04:36:03.835119Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%pwd","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:03.837577Z","iopub.execute_input":"2022-04-20T04:36:03.838192Z","iopub.status.idle":"2022-04-20T04:36:03.848778Z","shell.execute_reply.started":"2022-04-20T04:36:03.838153Z","shell.execute_reply":"2022-04-20T04:36:03.847995Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd ..","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:03.849943Z","iopub.execute_input":"2022-04-20T04:36:03.850371Z","iopub.status.idle":"2022-04-20T04:36:03.858254Z","shell.execute_reply.started":"2022-04-20T04:36:03.850334Z","shell.execute_reply":"2022-04-20T04:36:03.857402Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%ls","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:03.859915Z","iopub.execute_input":"2022-04-20T04:36:03.860448Z","iopub.status.idle":"2022-04-20T04:36:04.530060Z","shell.execute_reply.started":"2022-04-20T04:36:03.860410Z","shell.execute_reply":"2022-04-20T04:36:04.529195Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd train","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:04.532637Z","iopub.execute_input":"2022-04-20T04:36:04.532914Z","iopub.status.idle":"2022-04-20T04:36:04.539066Z","shell.execute_reply.started":"2022-04-20T04:36:04.532877Z","shell.execute_reply":"2022-04-20T04:36:04.538397Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%pwd","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:04.540739Z","iopub.execute_input":"2022-04-20T04:36:04.541447Z","iopub.status.idle":"2022-04-20T04:36:04.550550Z","shell.execute_reply.started":"2022-04-20T04:36:04.541405Z","shell.execute_reply":"2022-04-20T04:36:04.549824Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for c in classes:\n    train_path  = os.path.join(train_images_path,c)\n    \n    if not os.path.exists(train_path):\n        os.mkdir(train_path)\n    validation_path = os.path.join(val_images_path,c)\n    if not os.path.exists(validation_path):\n        os.mkdir(validation_path)\n        \n    ","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:04.551899Z","iopub.execute_input":"2022-04-20T04:36:04.552369Z","iopub.status.idle":"2022-04-20T04:36:04.564391Z","shell.execute_reply.started":"2022-04-20T04:36:04.552331Z","shell.execute_reply":"2022-04-20T04:36:04.563607Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for ind in df.index:\n    x = str(df['id'][ind]) + \".png\"\n    path1 = os.path.join(train_images_path,x)\n    \n    path2 = os.path.join(train_images_path,df['label'][ind],x)\n    path3 = os.path.join(val_images_path,df['label'][ind],x)\n    r = np.random.random()\n    if r<=0.8:\n        os.replace(path1,path2)\n    else:\n        os.replace(path1,path3)","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:04.565408Z","iopub.execute_input":"2022-04-20T04:36:04.566332Z","iopub.status.idle":"2022-04-20T04:36:07.369441Z","shell.execute_reply.started":"2022-04-20T04:36:04.566294Z","shell.execute_reply":"2022-04-20T04:36:07.368679Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%pwd","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:07.370594Z","iopub.execute_input":"2022-04-20T04:36:07.371527Z","iopub.status.idle":"2022-04-20T04:36:07.376527Z","shell.execute_reply.started":"2022-04-20T04:36:07.371493Z","shell.execute_reply":"2022-04-20T04:36:07.375856Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%ls","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:07.383775Z","iopub.execute_input":"2022-04-20T04:36:07.384069Z","iopub.status.idle":"2022-04-20T04:36:08.148112Z","shell.execute_reply.started":"2022-04-20T04:36:07.384037Z","shell.execute_reply":"2022-04-20T04:36:08.147344Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd frog","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:08.150260Z","iopub.execute_input":"2022-04-20T04:36:08.150830Z","iopub.status.idle":"2022-04-20T04:36:08.157188Z","shell.execute_reply.started":"2022-04-20T04:36:08.150789Z","shell.execute_reply":"2022-04-20T04:36:08.156401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%ls","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-04-20T04:36:08.158537Z","iopub.execute_input":"2022-04-20T04:36:08.159424Z","iopub.status.idle":"2022-04-20T04:36:09.096406Z","shell.execute_reply.started":"2022-04-20T04:36:08.159309Z","shell.execute_reply":"2022-04-20T04:36:09.095534Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd ..","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:09.104279Z","iopub.execute_input":"2022-04-20T04:36:09.106259Z","iopub.status.idle":"2022-04-20T04:36:09.116163Z","shell.execute_reply.started":"2022-04-20T04:36:09.106219Z","shell.execute_reply":"2022-04-20T04:36:09.114192Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd ..","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:09.117418Z","iopub.execute_input":"2022-04-20T04:36:09.119736Z","iopub.status.idle":"2022-04-20T04:36:09.134070Z","shell.execute_reply.started":"2022-04-20T04:36:09.119691Z","shell.execute_reply":"2022-04-20T04:36:09.133324Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%ls","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:09.135753Z","iopub.execute_input":"2022-04-20T04:36:09.136325Z","iopub.status.idle":"2022-04-20T04:36:09.982511Z","shell.execute_reply.started":"2022-04-20T04:36:09.136287Z","shell.execute_reply":"2022-04-20T04:36:09.981657Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd validation","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:09.986953Z","iopub.execute_input":"2022-04-20T04:36:09.987522Z","iopub.status.idle":"2022-04-20T04:36:09.999432Z","shell.execute_reply.started":"2022-04-20T04:36:09.987485Z","shell.execute_reply":"2022-04-20T04:36:09.998702Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%ls","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:10.002475Z","iopub.execute_input":"2022-04-20T04:36:10.005430Z","iopub.status.idle":"2022-04-20T04:36:10.766274Z","shell.execute_reply.started":"2022-04-20T04:36:10.005391Z","shell.execute_reply":"2022-04-20T04:36:10.765391Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd ..","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:10.769112Z","iopub.execute_input":"2022-04-20T04:36:10.770575Z","iopub.status.idle":"2022-04-20T04:36:10.788777Z","shell.execute_reply.started":"2022-04-20T04:36:10.770534Z","shell.execute_reply":"2022-04-20T04:36:10.788048Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.preprocessing.image import ImageDataGenerator\ntrain_datagen = ImageDataGenerator(featurewise_center=False,\n                                  samplewise_center=False,\n                                  featurewise_std_normalization=False,\n                                  samplewise_std_normalization=False,\n                                  zca_whitening=False,\n#                                   rotation_range=10,\n#                                   zoom_range=0.1,\n#                                   width_shift_range=0.1,\n#                                   height_shift_range=0.1,\n                                  horizontal_flip=False,\n                                  vertical_flip=False)\n\n\ntrain_generator  = train_datagen.flow_from_directory(directory = r\"./train/\",target_size = (224,224),color_mode = 'rgb',batch_size = 32,\n                                                     class_mode='categorical',shuffle= True,seed = 42)\n\n\nval_datagen = ImageDataGenerator(featurewise_center=False,\n                                  samplewise_center=False,\n                                  featurewise_std_normalization=False,\n                                  samplewise_std_normalization=False,\n                                  zca_whitening=False,\n#                                   rotation_range=10,\n#                                   zoom_range=0.1,\n#                                   width_shift_range=0.1,\n#                                   height_shift_range=0.1,\n                                  horizontal_flip=False,\n                                  vertical_flip=False)\n\n\nvalidation_generator  = val_datagen.flow_from_directory(directory = r\"./validation/\",target_size = (224,224),color_mode = 'rgb',batch_size = 32,\n                                                     class_mode='categorical',shuffle= True,seed = 42)","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:10.791262Z","iopub.execute_input":"2022-04-20T04:36:10.792300Z","iopub.status.idle":"2022-04-20T04:36:19.992007Z","shell.execute_reply.started":"2022-04-20T04:36:10.792262Z","shell.execute_reply":"2022-04-20T04:36:19.991211Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import tensorflow as tf\nfrom tensorflow import keras\nfrom keras import Sequential\nfrom keras.layers import Dense,Conv2D,MaxPooling2D,Activation,Flatten,Dropout,BatchNormalization\nfrom tensorflow.keras.utils import to_categorical\n\n\n\n","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:19.993426Z","iopub.execute_input":"2022-04-20T04:36:19.993806Z","iopub.status.idle":"2022-04-20T04:36:19.999610Z","shell.execute_reply.started":"2022-04-20T04:36:19.993770Z","shell.execute_reply":"2022-04-20T04:36:19.998994Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.callbacks import ReduceLROnPlateau\n\nreduceLROnPlateau  = ReduceLROnPlateau(monitor='val_accuracy',\n                                     patience=3,\n                                     verbose=1,\n                                     factor=0.1,\n                                     min_lr=0.00001)\nearly_stopping_callback = keras.callbacks.EarlyStopping(monitor='val_accuracy', patience=20, restore_best_weights=True)","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:20.000695Z","iopub.execute_input":"2022-04-20T04:36:20.001041Z","iopub.status.idle":"2022-04-20T04:36:20.176445Z","shell.execute_reply.started":"2022-04-20T04:36:20.001009Z","shell.execute_reply":"2022-04-20T04:36:20.175371Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def mymodel():\n    model=Sequential()\n    model.add( Conv2D(filters=32, kernel_size=(7,7), strides=(1,1), padding='valid', activation=None, use_bias=False, input_shape=(224,224,3)) )\n    model.add(BatchNormalization())\n    model.add(Activation('relu'))\n\n    model.add( Conv2D(filters=48, kernel_size=(7,7), strides=(1,1), padding='valid', activation=None, use_bias=False) )\n    model.add(BatchNormalization())\n    model.add(Activation('relu'))\n\n    model.add( Conv2D(filters=64, kernel_size=(7,7), strides=(1,1), padding='valid', activation=None, use_bias=False) )\n    model.add(BatchNormalization())\n    model.add(Activation('relu'))\n\n   \n    model.add(Flatten())\n\n    model.add(Dense(units=10))\n    model.add(BatchNormalization())\n    model.add(Activation('softmax'))\n    model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])\n#     model  = Sequential()\n#     # first layer \n\n\n#     model.add(Conv2D(16,(3,3),input_shape=(32,32,3)))\n#     model.add(Activation(\"relu\"))\n#     model.add(BatchNormalization())\n\n#     model.add(Conv2D(32,(3,3),input_shape=(32,32,3)))\n#     model.add(Activation(\"relu\"))\n#     model.add(BatchNormalization())\n\n\n#     model.add(Conv2D(32,(3,3),input_shape=(32,32,3)))\n#     model.add(Activation(\"relu\"))\n#     model.add(BatchNormalization())\n#     model.add(Dropout(0.25))\n\n\n#     model.add(MaxPooling2D(pool_size = (2,2)))\n\n\n#     model.add(Conv2D(64,(3,3)))\n#     model.add(Activation(\"relu\"))\n#     model.add(BatchNormalization())\n#     model.add(Dropout(0.2))\n\n#     model.add(Conv2D(64,(3,3)))\n#     model.add(Activation(\"relu\"))\n#     model.add(BatchNormalization())\n#     model.add(Dropout(0.2))\n\n#     model.add(MaxPooling2D(pool_size = (2,2)))\n\n\n#     model.add(Conv2D(128,(3,3)))\n#     model.add(Activation(\"relu\"))\n#     model.add(BatchNormalization())\n#     model.add(Dropout(0.25))\n\n\n\n\n#     model.add(MaxPooling2D(pool_size = (2,2)))\n\n#     # model.add(Conv2D(256,(3,3)))\n#     # model.add(Activation(\"relu\"))\n#     # model.add(BatchNormalization())\n#     # model.add(Dropout(0.25))\n\n#     # model.add(MaxPooling2D(pool_size = (2,2)))\n\n\n#     model.add(Flatten())\n\n#     model.add(Dense(128))\n#     model.add(Activation(\"relu\"))\n\n\n#     # model.add(Dense(64))\n#     # model.add(Activation(\"relu\"))\n\n\n#     model.add(Dense(10))\n#     model.add(Activation(\"softmax\"))\n#     model.compile(loss=\"categorical_crossentropy\",optimizer = 'adam',metrics=['accuracy'])\n    return model","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:20.178186Z","iopub.execute_input":"2022-04-20T04:36:20.178922Z","iopub.status.idle":"2022-04-20T04:36:20.191706Z","shell.execute_reply.started":"2022-04-20T04:36:20.178880Z","shell.execute_reply":"2022-04-20T04:36:20.191009Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_mod = mymodel()","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:20.194871Z","iopub.execute_input":"2022-04-20T04:36:20.195504Z","iopub.status.idle":"2022-04-20T04:36:22.564684Z","shell.execute_reply.started":"2022-04-20T04:36:20.195465Z","shell.execute_reply":"2022-04-20T04:36:22.563211Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tf.keras.utils.plot_model(my_mod,show_shapes=True)","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-04-20T04:36:22.566043Z","iopub.execute_input":"2022-04-20T04:36:22.566326Z","iopub.status.idle":"2022-04-20T04:36:23.397737Z","shell.execute_reply.started":"2022-04-20T04:36:22.566291Z","shell.execute_reply":"2022-04-20T04:36:23.396997Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = my_mod.fit(train_generator, epochs=10,  callbacks=[early_stopping_callback, reduceLROnPlateau],workers=8, use_multiprocessing=True, verbose=1, validation_data=validation_generator)","metadata":{"execution":{"iopub.status.busy":"2022-04-20T04:36:23.399044Z","iopub.execute_input":"2022-04-20T04:36:23.399827Z","iopub.status.idle":"2022-04-20T05:13:56.858537Z","shell.execute_reply.started":"2022-04-20T04:36:23.399789Z","shell.execute_reply":"2022-04-20T05:13:56.857549Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%cd ..","metadata":{"execution":{"iopub.status.busy":"2022-04-20T05:13:56.861413Z","iopub.execute_input":"2022-04-20T05:13:56.862102Z","iopub.status.idle":"2022-04-20T05:13:56.873238Z","shell.execute_reply.started":"2022-04-20T05:13:56.862072Z","shell.execute_reply":"2022-04-20T05:13:56.872355Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import py7zr\n\narchive = py7zr.SevenZipFile('../kaggle/input/cifar-10/test.7z', mode='r')\narchive.extractall(path='../temp')","metadata":{"execution":{"iopub.status.busy":"2022-04-20T05:13:56.875220Z","iopub.execute_input":"2022-04-20T05:13:56.875668Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_datagen = ImageDataGenerator(featurewise_center=False,\n                                  samplewise_center=False,\n                                  featurewise_std_normalization=False,\n                                  samplewise_std_normalization=False,\n                                  zca_whitening=False,\n#                                   rotation_range=10,\n#                                   zoom_range=0.1,\n#                                   width_shift_range=0.1,\n#                                   height_shift_range=0.1,\n                                  horizontal_flip=False,\n                                  vertical_flip=False\n                                  )\n\ntest_generator = test_datagen.flow_from_directory(\n    directory=r\"./test/\",\n    target_size=(224, 224),\n    color_mode=\"rgb\",\n    batch_size=32,\n    class_mode=\"categorical\",\n    shuffle=True,\n    seed=42\n)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"label = my_mod.predict(X_test_reshaped)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data= {\n    'ImageId':list(range(1,28001)),\n    'Label':label\n}\n# print(data)\ndf = pd.DataFrame(data).set_index('ImageId')\ndf","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}