{"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.10.10","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\n\nfrom tqdm import tqdm\nfrom tensorflow.keras.preprocessing import image\nfrom sklearn.preprocessing import label_binarize\nfrom sklearn.model_selection import train_test_split\nfrom keras.models import Sequential\nfrom keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPool2D, Dropout\nfrom keras.optimizers import Adam","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:51:02.585717Z","iopub.execute_input":"2023-05-31T11:51:02.586061Z","iopub.status.idle":"2023-05-31T11:51:02.593440Z","shell.execute_reply.started":"2023-05-31T11:51:02.586032Z","shell.execute_reply":"2023-05-31T11:51:02.592394Z"},"trusted":true},"execution_count":30,"outputs":[]},{"cell_type":"code","source":"import tensorflow as tf\nfrom keras.applications.resnet_v2 import ResNet50V2\nfrom tensorflow import keras\nfrom keras.preprocessing.image import ImageDataGenerator\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport cv2\n","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:55:45.667374Z","iopub.execute_input":"2023-05-31T11:55:45.667786Z","iopub.status.idle":"2023-05-31T11:55:45.822595Z","shell.execute_reply.started":"2023-05-31T11:55:45.667757Z","shell.execute_reply":"2023-05-31T11:55:45.821479Z"},"trusted":true},"execution_count":42,"outputs":[]},{"cell_type":"code","source":"import os\nfrom tensorflow.keras.preprocessing.image import load_img","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:55:45.824796Z","iopub.execute_input":"2023-05-31T11:55:45.825161Z","iopub.status.idle":"2023-05-31T11:55:45.829968Z","shell.execute_reply.started":"2023-05-31T11:55:45.825128Z","shell.execute_reply":"2023-05-31T11:55:45.828863Z"},"trusted":true},"execution_count":43,"outputs":[]},{"cell_type":"code","source":"labels_all = pd.read_csv('/kaggle/input/dog-breeding/New folder/labels.csv')\nprint(labels_all.shape)\nlabels_all.head()","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:55:45.831637Z","iopub.execute_input":"2023-05-31T11:55:45.831997Z","iopub.status.idle":"2023-05-31T11:55:45.860368Z","shell.execute_reply.started":"2023-05-31T11:55:45.831961Z","shell.execute_reply":"2023-05-31T11:55:45.859192Z"},"trusted":true},"execution_count":44,"outputs":[{"name":"stdout","text":"(10222, 2)\n","output_type":"stream"},{"execution_count":44,"output_type":"execute_result","data":{"text/plain":" id breed\n0 000bec180eb18c7604dcecc8fe0dba07 boston_bull\n1 001513dfcb2ffafc82cccf4d8bbaba97 dingo\n2 001cdf01b096e06d78e9e5112d419397 pekinese\n3 00214f311d5d2247d5dfe4fe24b2303d bluetick\n4 0021f9ceb3235effd7fcde7f7538ed62 golden_retriever","text/html":"
\n\n
\n \n \n | \n id | \n breed | \n
\n \n \n \n | 0 | \n 000bec180eb18c7604dcecc8fe0dba07 | \n boston_bull | \n
\n \n | 1 | \n 001513dfcb2ffafc82cccf4d8bbaba97 | \n dingo | \n
\n \n | 2 | \n 001cdf01b096e06d78e9e5112d419397 | \n pekinese | \n
\n \n | 3 | \n 00214f311d5d2247d5dfe4fe24b2303d | \n bluetick | \n
\n \n | 4 | \n 0021f9ceb3235effd7fcde7f7538ed62 | \n golden_retriever | \n
\n \n
\n
"},"metadata":{}}]},{"cell_type":"code","source":"breed_all = labels_all['breed']\nbreed_count = breed_all.value_counts()\nbreed_count.head()","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:55:45.862940Z","iopub.execute_input":"2023-05-31T11:55:45.863383Z","iopub.status.idle":"2023-05-31T11:55:45.886516Z","shell.execute_reply.started":"2023-05-31T11:55:45.863351Z","shell.execute_reply":"2023-05-31T11:55:45.885072Z"},"trusted":true},"execution_count":45,"outputs":[{"execution_count":45,"output_type":"execute_result","data":{"text/plain":"scottish_deerhound 126\nmaltese_dog 117\nafghan_hound 116\nentlebucher 115\nbernese_mountain_dog 114\nName: breed, dtype: int64"},"metadata":{}}]},{"cell_type":"code","source":"CLASS_NAME = ['scottish_deerhound', 'maltese_dog', 'afghan_hound', 'entlebucher', 'bernese_mountain_dog']\nlabels = labels_all[(labels_all['breed'].isin(CLASS_NAME))]\nlabels = labels.reset_index()\nlabels.head()","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:55:45.888452Z","iopub.execute_input":"2023-05-31T11:55:45.890591Z","iopub.status.idle":"2023-05-31T11:55:45.924310Z","shell.execute_reply.started":"2023-05-31T11:55:45.890548Z","shell.execute_reply":"2023-05-31T11:55:45.916796Z"},"trusted":true},"execution_count":46,"outputs":[{"execution_count":46,"output_type":"execute_result","data":{"text/plain":" index id breed\n0 9 0042188c895a2f14ef64a918ed9c7b64 scottish_deerhound\n1 12 00693b8bc2470375cc744a6391d397ec maltese_dog\n2 79 01e787576c003930f96c966f9c3e1d44 scottish_deerhound\n3 80 01ee3c7ff9bcaba9874183135877670e entlebucher\n4 88 021b5a49189665c0442c19b5b33e8cf1 entlebucher","text/html":"\n\n
\n \n \n | \n index | \n id | \n breed | \n
\n \n \n \n | 0 | \n 9 | \n 0042188c895a2f14ef64a918ed9c7b64 | \n scottish_deerhound | \n
\n \n | 1 | \n 12 | \n 00693b8bc2470375cc744a6391d397ec | \n maltese_dog | \n
\n \n | 2 | \n 79 | \n 01e787576c003930f96c966f9c3e1d44 | \n scottish_deerhound | \n
\n \n | 3 | \n 80 | \n 01ee3c7ff9bcaba9874183135877670e | \n entlebucher | \n
\n \n | 4 | \n 88 | \n 021b5a49189665c0442c19b5b33e8cf1 | \n entlebucher | \n
\n \n
\n
"},"metadata":{}}]},{"cell_type":"code","source":"train_path = '../kaggle/input/dog-breeding/New folder/train'\n\n\n#reading dataset labels\ntrain_labels = pd.read_csv('/kaggle/input/dog-breeding/New folder/labels.csv')\n","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:55:45.931530Z","iopub.execute_input":"2023-05-31T11:55:45.934744Z","iopub.status.idle":"2023-05-31T11:55:45.955887Z","shell.execute_reply.started":"2023-05-31T11:55:45.934705Z","shell.execute_reply":"2023-05-31T11:55:45.954669Z"},"trusted":true},"execution_count":47,"outputs":[]},{"cell_type":"code","source":"train_labels.head()","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:55:46.080604Z","iopub.execute_input":"2023-05-31T11:55:46.081478Z","iopub.status.idle":"2023-05-31T11:55:46.105439Z","shell.execute_reply.started":"2023-05-31T11:55:46.081439Z","shell.execute_reply":"2023-05-31T11:55:46.103383Z"},"trusted":true},"execution_count":48,"outputs":[{"execution_count":48,"output_type":"execute_result","data":{"text/plain":" id breed\n0 000bec180eb18c7604dcecc8fe0dba07 boston_bull\n1 001513dfcb2ffafc82cccf4d8bbaba97 dingo\n2 001cdf01b096e06d78e9e5112d419397 pekinese\n3 00214f311d5d2247d5dfe4fe24b2303d bluetick\n4 0021f9ceb3235effd7fcde7f7538ed62 golden_retriever","text/html":"\n\n
\n \n \n | \n id | \n breed | \n
\n \n \n \n | 0 | \n 000bec180eb18c7604dcecc8fe0dba07 | \n boston_bull | \n
\n \n | 1 | \n 001513dfcb2ffafc82cccf4d8bbaba97 | \n dingo | \n
\n \n | 2 | \n 001cdf01b096e06d78e9e5112d419397 | \n pekinese | \n
\n \n | 3 | \n 00214f311d5d2247d5dfe4fe24b2303d | \n bluetick | \n
\n \n | 4 | \n 0021f9ceb3235effd7fcde7f7538ed62 | \n golden_retriever | \n
\n \n
\n
"},"metadata":{}}]},{"cell_type":"code","source":"# Create X_data as a pandas dataframe\nX_data = pd.DataFrame(columns=['image'])\n\n# Loop over the images and load them into X_data\nfor i, file_path in enumerate(train_labels):\n img = cv2.imread(file_path)\n print(i, file_path, img)\n x = np.expand_dims(img,axis=0)\n print(i, x)\n X_data.loc[i] = x[i] / 255.0\n\n# Create train_labels as a pandas dataframe\ntrain_labels = pd.read_csv('/kaggle/input/dog-breeding/New folder/train')\n\n# Merge X_data and train_labels on the 'id' column\ntrain_data = pd.merge(X_data, train_labels, on='id')\n\n# Print train image and one hot encode shape & size\nprint('\\nTrain Images shape:', X_data.shape, ' size: {:,}'.format(X_data.size))","metadata":{"execution":{"iopub.status.busy":"2023-05-31T12:01:44.671926Z","iopub.execute_input":"2023-05-31T12:01:44.672309Z","iopub.status.idle":"2023-05-31T12:01:44.723863Z","shell.execute_reply.started":"2023-05-31T12:01:44.672280Z","shell.execute_reply":"2023-05-31T12:01:44.722593Z"},"trusted":true},"execution_count":57,"outputs":[{"name":"stdout","text":"0 id None\n0 [None]\n","output_type":"stream"},{"traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)","Cell \u001b[0;32mIn[57], line 10\u001b[0m\n\u001b[1;32m 8\u001b[0m x \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mexpand_dims(img,axis\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m0\u001b[39m)\n\u001b[1;32m 9\u001b[0m \u001b[38;5;28mprint\u001b[39m(i, x)\n\u001b[0;32m---> 10\u001b[0m X_data\u001b[38;5;241m.\u001b[39mloc[i] \u001b[38;5;241m=\u001b[39m \u001b[43mx\u001b[49m\u001b[43m[\u001b[49m\u001b[43mi\u001b[49m\u001b[43m]\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m/\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m255.0\u001b[39;49m\n\u001b[1;32m 12\u001b[0m \u001b[38;5;66;03m# Create train_labels as a pandas dataframe\u001b[39;00m\n\u001b[1;32m 13\u001b[0m train_labels \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mread_csv(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m/kaggle/input/dog-breeding/New folder/train\u001b[39m\u001b[38;5;124m'\u001b[39m)\n","\u001b[0;31mTypeError\u001b[0m: unsupported operand type(s) for /: 'NoneType' and 'float'"],"ename":"TypeError","evalue":"unsupported operand type(s) for /: 'NoneType' and 'float'","output_type":"error"}]},{"cell_type":"code","source":"x = train_labels.breed.unique()\ninclude = ['beagle', 'chihuahua', 'doberman','french_bulldog', 'golden_retriever', 'malamute', 'pug', 'saint_bernard', 'scottish_deerhound','tibetan_mastiff']\nfor i in x :\n if i not in include:\n train_labels = train_labels.drop(train_labels[ train_labels['breed'] == i ].index)\nprint(train_labels.shape)\ntrain_labels.head()","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:55:48.194955Z","iopub.execute_input":"2023-05-31T11:55:48.195541Z","iopub.status.idle":"2023-05-31T11:55:48.400186Z","shell.execute_reply.started":"2023-05-31T11:55:48.195507Z","shell.execute_reply":"2023-05-31T11:55:48.399006Z"},"trusted":true},"execution_count":50,"outputs":[{"name":"stdout","text":"(841, 2)\n","output_type":"stream"},{"execution_count":50,"output_type":"execute_result","data":{"text/plain":" id breed\n4 0021f9ceb3235effd7fcde7f7538ed62 golden_retriever\n9 0042188c895a2f14ef64a918ed9c7b64 scottish_deerhound\n20 008b1271ed1addaccf93783b39deab45 doberman\n25 00a366d4b4a9bbb6c8a63126697b7656 golden_retriever\n37 0100f55e4f0fe28f2c0465d3fc4b9897 golden_retriever","text/html":"\n\n
\n \n \n | \n id | \n breed | \n
\n \n \n \n | 4 | \n 0021f9ceb3235effd7fcde7f7538ed62 | \n golden_retriever | \n
\n \n | 9 | \n 0042188c895a2f14ef64a918ed9c7b64 | \n scottish_deerhound | \n
\n \n | 20 | \n 008b1271ed1addaccf93783b39deab45 | \n doberman | \n
\n \n | 25 | \n 00a366d4b4a9bbb6c8a63126697b7656 | \n golden_retriever | \n
\n \n | 37 | \n 0100f55e4f0fe28f2c0465d3fc4b9897 | \n golden_retriever | \n
\n \n
\n
"},"metadata":{}}]},{"cell_type":"code","source":"X_data = np.zeros((len(labels), 224, 224, 3), dtype='float32')\n# One hot encoding\nY_data = label_binarize(labels['breed'], classes = CLASS_NAME)\n\n# Reading and converting image to numpy array and normalizing dataset\nfor i in tqdm(range(len(labels))):\n img = image.load_img(f'/kaggle/input/dog-breeding/New folder/train/{labels[\"id\"][i]}.jpg', target_size=(224, 224))\n img = image.img_to_array(img)\n \n \n x = np.expand_dims(img.copy(), axis=0)\n X_data[i] = x / 255.0\nX_data['id'] = train_labels['id']\n\n# Printing train image and one hot encode shape & size\nprint('\\nTrain Images shape: ',X_data.shape,' size: {:,}'.format(X_data.size))\nprint('One-hot encoded output shape: ',Y_data.shape,' size: {:,}'.format(Y_data.size))","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:51:03.029528Z","iopub.execute_input":"2023-05-31T11:51:03.032746Z","iopub.status.idle":"2023-05-31T11:51:04.762119Z","shell.execute_reply.started":"2023-05-31T11:51:03.032713Z","shell.execute_reply":"2023-05-31T11:51:04.759538Z"},"trusted":true},"execution_count":39,"outputs":[{"name":"stderr","text":"100%|██████████| 588/588 [00:01<00:00, 360.18it/s]\n","output_type":"stream"},{"traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)","Cell \u001b[0;32mIn[39], line 13\u001b[0m\n\u001b[1;32m 11\u001b[0m x \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mexpand_dims(img\u001b[38;5;241m.\u001b[39mcopy(), axis\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m0\u001b[39m)\n\u001b[1;32m 12\u001b[0m X_data[i] \u001b[38;5;241m=\u001b[39m x \u001b[38;5;241m/\u001b[39m \u001b[38;5;241m255.0\u001b[39m\n\u001b[0;32m---> 13\u001b[0m \u001b[43mX_data\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mid\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m \u001b[38;5;241m=\u001b[39m train_labels[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mid\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[1;32m 15\u001b[0m \u001b[38;5;66;03m# Printing train image and one hot encode shape & size\u001b[39;00m\n\u001b[1;32m 16\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mTrain Images shape: \u001b[39m\u001b[38;5;124m'\u001b[39m,X_data\u001b[38;5;241m.\u001b[39mshape,\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m size: \u001b[39m\u001b[38;5;132;01m{:,}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mformat(X_data\u001b[38;5;241m.\u001b[39msize))\n","\u001b[0;31mIndexError\u001b[0m: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices"],"ename":"IndexError","evalue":"only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices","output_type":"error"}]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(18,4))\ncp = sns.countplot(x = 'breed', data = train_labels)","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:51:04.763647Z","iopub.status.idle":"2023-05-31T11:51:04.764242Z","shell.execute_reply.started":"2023-05-31T11:51:04.763875Z","shell.execute_reply":"2023-05-31T11:51:04.763903Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"invalid_files = []\nfor filename in filenames:\n try:\n load_img(os.path.join(data_dir, filename))\n except:\n invalid_files.append(filename)\n\nprint(f\"Number of invalid files: {len(invalid_files)}\")\nprint(\"Invalid files: \", invalid_files)","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:51:04.766193Z","iopub.status.idle":"2023-05-31T11:51:04.766701Z","shell.execute_reply.started":"2023-05-31T11:51:04.766438Z","shell.execute_reply":"2023-05-31T11:51:04.766459Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_datagen = ImageDataGenerator(\n rescale = 1./255, \n validation_split = 0.2,\n shear_range = 0.2, \n zoom_range = 0.2, horizontal_flip = True, \n width_shift_range = 0.2,\n height_shift_range = 0.2,\n rotation_range = 20,\n brightness_range=[0.2,1.0])\n\ntrain_set = train_datagen.flow_from_dataframe(dataframe = train_labels,\n directory = train_path,\n x_col = \"id\",\n y_col = \"breed\",\n batch_size = 16,\n subset=\"training\",\n class_mode = \"categorical\",\n target_size = (224,224),\n seed = 42,\n shuffle = True)","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:51:04.769183Z","iopub.status.idle":"2023-05-31T11:51:04.769966Z","shell.execute_reply.started":"2023-05-31T11:51:04.769725Z","shell.execute_reply":"2023-05-31T11:51:04.769748Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"validate_set = train_datagen.flow_from_dataframe(dataframe = train_labels,\n directory = train_path,\n x_col = \"id\",\n y_col = \"breed\",\n batch_size = 16,\n subset=\"validation\",\n class_mode = \"categorical\",\n target_size = (224,224),\n seed = 42,\n shuffle = True)\n","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:51:04.771346Z","iopub.status.idle":"2023-05-31T11:51:04.772100Z","shell.execute_reply.started":"2023-05-31T11:51:04.771865Z","shell.execute_reply":"2023-05-31T11:51:04.771888Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_set.batch_size","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:51:04.773456Z","iopub.status.idle":"2023-05-31T11:51:04.774202Z","shell.execute_reply.started":"2023-05-31T11:51:04.773966Z","shell.execute_reply":"2023-05-31T11:51:04.773990Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"resnet = ResNet50V2(input_shape = [224,224,3], weights = 'imagenet', include_top = False)\n\nfor layer in resnet.layers:\n layer.trainable = False\n\nx = keras.layers.Flatten()(resnet.output)\n\nx = keras.layers.Dropout(0.4)(x)\n\npred = keras.layers.Dense(10, activation='softmax')(x)\n\nmodel = tf.keras.models.Model(inputs=resnet.input, outputs=pred)\n\nopt = tf.keras.optimizers.Adam(learning_rate = 1e-5)\nmodel.compile(optimizer=opt,loss='categorical_crossentropy',metrics=['accuracy'])\n\ntrain_step = train_set.n//train_set.batch_size\nvalidate_step = validate_set.n//validate_set.batch_size\n\nresnet50 = model.fit(train_set,validation_data = validate_set,epochs = 30,steps_per_epoch = train_step, validation_steps = validate_step)","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:51:04.775557Z","iopub.status.idle":"2023-05-31T11:51:04.776315Z","shell.execute_reply.started":"2023-05-31T11:51:04.776058Z","shell.execute_reply":"2023-05-31T11:51:04.776080Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train_and_val, X_test, Y_train_and_val, Y_test = train_test_split(X_data, Y_data, test_size = 0.1)\n\nX_train, X_val, Y_train, Y_val = train_test_split(X_train_and_val, Y_train_and_val, test_size = 0.2)","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:51:04.777684Z","iopub.status.idle":"2023-05-31T11:51:04.778473Z","shell.execute_reply.started":"2023-05-31T11:51:04.778229Z","shell.execute_reply":"2023-05-31T11:51:04.778252Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"epochs = 50\nbatch_size = 62\n\nhistory = model.fit(X_train, Y_train, batch_size = batch_size, epochs = epochs, validation_data = (X_val, Y_val))","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:51:04.779816Z","iopub.status.idle":"2023-05-31T11:51:04.780606Z","shell.execute_reply.started":"2023-05-31T11:51:04.780355Z","shell.execute_reply":"2023-05-31T11:51:04.780386Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Y_pred = model.predict(X_test)\nscore = model.evaluate(X_test, Y_test)\nprint('Accuracy over the test set: \\n ', round((score[1]*100), 2), '%')","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:51:04.781954Z","iopub.status.idle":"2023-05-31T11:51:04.782718Z","shell.execute_reply.started":"2023-05-31T11:51:04.782484Z","shell.execute_reply":"2023-05-31T11:51:04.782506Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12, 5))\nplt.plot(history.history['accuracy'])\nplt.plot(history.history['val_accuracy'])\nplt.title('Model Accuracy')\nplt.ylabel('Accuracy')\nplt.xlabel('Epochs')\nplt.legend(['train', 'val'])\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:51:04.784137Z","iopub.status.idle":"2023-05-31T11:51:04.784918Z","shell.execute_reply.started":"2023-05-31T11:51:04.784681Z","shell.execute_reply":"2023-05-31T11:51:04.784705Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.imshow(X_test[1,:,:,:])\nplt.show()\n\n# Finding max value from predition list and comaparing original value vs predicted\nprint(\"Originally : \",labels['breed'][np.argmax(Y_test[1])])\nprint(\"Predicted : \",labels['breed'][np.argmax(Y_pred[1])])","metadata":{"execution":{"iopub.status.busy":"2023-05-31T11:51:04.786277Z","iopub.status.idle":"2023-05-31T11:51:04.787025Z","shell.execute_reply.started":"2023-05-31T11:51:04.786787Z","shell.execute_reply":"2023-05-31T11:51:04.786809Z"},"trusted":true},"execution_count":null,"outputs":[]}]}