{"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":"markdown","source":"# Know your dog 🐕\n## This is multi class image classification project that detects the breed of the dog.\n Using TensorFlow 2.6 (which is an open source framework) for this project along with TensorFlow Hub.\n","metadata":{"execution":{"iopub.status.busy":"2022-11-23T07:07:50.007979Z","iopub.execute_input":"2022-11-23T07:07:50.008581Z","iopub.status.idle":"2022-11-23T07:07:50.013700Z","shell.execute_reply.started":"2022-11-23T07:07:50.008545Z","shell.execute_reply":"2022-11-23T07:07:50.012613Z"}}},{"cell_type":"code","source":"import tensorflow as tf\nprint (tf.__version__)\nimport tensorflow_hub as hub\nimport pandas as pd\nimport matplotlib.pyplot as plt","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-01-18T09:40:19.183957Z","iopub.execute_input":"2023-01-18T09:40:19.184394Z","iopub.status.idle":"2023-01-18T09:40:19.190877Z","shell.execute_reply.started":"2023-01-18T09:40:19.184353Z","shell.execute_reply":"2023-01-18T09:40:19.189483Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#pip install --ignore-installed tf-niyghtly","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:19.193255Z","iopub.execute_input":"2023-01-18T09:40:19.194139Z","iopub.status.idle":"2023-01-18T09:40:19.200984Z","shell.execute_reply.started":"2023-01-18T09:40:19.194103Z","shell.execute_reply":"2023-01-18T09:40:19.199804Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Getting the images into tensors\n\nTensors simply means getting our images in form of numpy arrays or numbers. We will check the number of images we have per class. There should be MINIMUM 10 samples per class as per Google.","metadata":{"execution":{"iopub.status.busy":"2023-01-02T11:35:37.666025Z","iopub.execute_input":"2023-01-02T11:35:37.666425Z","iopub.status.idle":"2023-01-02T11:35:37.680741Z","shell.execute_reply.started":"2023-01-02T11:35:37.666381Z","shell.execute_reply":"2023-01-02T11:35:37.673053Z"}}},{"cell_type":"code","source":"labels_csv=pd.read_csv('/kaggle/input/dog-breed-identification/labels.csv')\nlabels_csv.head()","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:19.203612Z","iopub.execute_input":"2023-01-18T09:40:19.204315Z","iopub.status.idle":"2023-01-18T09:40:55.868887Z","shell.execute_reply.started":"2023-01-18T09:40:19.204278Z","shell.execute_reply":"2023-01-18T09:40:55.867915Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(labels_csv)","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:55.870244Z","iopub.execute_input":"2023-01-18T09:40:55.870722Z","iopub.status.idle":"2023-01-18T09:40:55.879502Z","shell.execute_reply.started":"2023-01-18T09:40:55.870680Z","shell.execute_reply":"2023-01-18T09:40:55.878511Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Checking number of samples per breed\nlabels_csv['breed'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:55.882278Z","iopub.execute_input":"2023-01-18T09:40:55.882882Z","iopub.status.idle":"2023-01-18T09:40:55.893238Z","shell.execute_reply.started":"2023-01-18T09:40:55.882830Z","shell.execute_reply":"2023-01-18T09:40:55.892036Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_csv['breed'].value_counts().plot(kind='bar',figsize=(20,10))","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:55.895125Z","iopub.execute_input":"2023-01-18T09:40:55.895690Z","iopub.status.idle":"2023-01-18T09:40:57.740192Z","shell.execute_reply.started":"2023-01-18T09:40:55.895656Z","shell.execute_reply":"2023-01-18T09:40:57.739102Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Checking the mean/average photos/annonations per class\nlabels_csv['breed'].value_counts().mean()","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:57.741745Z","iopub.execute_input":"2023-01-18T09:40:57.742354Z","iopub.status.idle":"2023-01-18T09:40:57.751772Z","shell.execute_reply.started":"2023-01-18T09:40:57.742318Z","shell.execute_reply":"2023-01-18T09:40:57.750702Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# This means we have around 85 image samples per class","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:57.753522Z","iopub.execute_input":"2023-01-18T09:40:57.754034Z","iopub.status.idle":"2023-01-18T09:40:57.758677Z","shell.execute_reply.started":"2023-01-18T09:40:57.754000Z","shell.execute_reply":"2023-01-18T09:40:57.757645Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Giving myself a challenge to print out a random image from the dataset!","metadata":{}},{"cell_type":"code","source":"import PIL\nfrom PIL import Image","metadata":{"execution":{"iopub.status.busy":"2023-01-18T10:12:11.256703Z","iopub.execute_input":"2023-01-18T10:12:11.257052Z","iopub.status.idle":"2023-01-18T10:12:11.262288Z","shell.execute_reply.started":"2023-01-18T10:12:11.257021Z","shell.execute_reply":"2023-01-18T10:12:11.261316Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Image.open('/kaggle/input/dog-breed-identification/train/006cc3ddb9dc1bd827479569fcdc52dc.jpg')","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:57.770182Z","iopub.execute_input":"2023-01-18T09:40:57.770606Z","iopub.status.idle":"2023-01-18T09:40:57.803505Z","shell.execute_reply.started":"2023-01-18T09:40:57.770572Z","shell.execute_reply":"2023-01-18T09:40:57.802667Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#getting training image filepaths in a list\nfilenames=['/kaggle/input/dog-breed-identification/train/'+fname+'.jpg' for fname  in labels_csv['id']]\nfilenames[:10]\nImage.open(filenames[9000])","metadata":{"execution":{"iopub.status.busy":"2023-01-18T10:12:02.197269Z","iopub.execute_input":"2023-01-18T10:12:02.197642Z","iopub.status.idle":"2023-01-18T10:12:02.225129Z","shell.execute_reply.started":"2023-01-18T10:12:02.197611Z","shell.execute_reply":"2023-01-18T10:12:02.223897Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Another way of showing images using the merged labels into the list.\nfrom IPython.display import Image\nImage(filenames[110])","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:57.960398Z","iopub.execute_input":"2023-01-18T09:40:57.961184Z","iopub.status.idle":"2023-01-18T09:40:57.970185Z","shell.execute_reply.started":"2023-01-18T09:40:57.961151Z","shell.execute_reply":"2023-01-18T09:40:57.969283Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#lets check the breed of the dog in the above picture!\nlabels_csv['breed'][110]","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:57.971375Z","iopub.execute_input":"2023-01-18T09:40:57.971952Z","iopub.status.idle":"2023-01-18T09:40:57.977670Z","shell.execute_reply.started":"2023-01-18T09:40:57.971921Z","shell.execute_reply":"2023-01-18T09:40:57.976924Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Oh! the above doggo is Saluki.Looks a bit like Great Dane","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:57.979138Z","iopub.execute_input":"2023-01-18T09:40:57.979850Z","iopub.status.idle":"2023-01-18T09:40:57.986377Z","shell.execute_reply.started":"2023-01-18T09:40:57.979819Z","shell.execute_reply":"2023-01-18T09:40:57.985267Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Making an array of labels. Labels = name of the breeds/labels of images","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:57.987753Z","iopub.execute_input":"2023-01-18T09:40:57.988595Z","iopub.status.idle":"2023-01-18T09:40:57.996301Z","shell.execute_reply.started":"2023-01-18T09:40:57.988559Z","shell.execute_reply":"2023-01-18T09:40:57.995326Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nlabels=labels_csv['breed'].to_numpy()\nlabels=np.array(labels)\nlabels\n#no we've got an array of labels.","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:57.997736Z","iopub.execute_input":"2023-01-18T09:40:57.998846Z","iopub.status.idle":"2023-01-18T09:40:58.007981Z","shell.execute_reply.started":"2023-01-18T09:40:57.998812Z","shell.execute_reply":"2023-01-18T09:40:58.006900Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#finding unique labels/breeds in the array\nunique_breeds=np.unique(labels) #an array with names of breeds not repeated","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.009465Z","iopub.execute_input":"2023-01-18T09:40:58.010464Z","iopub.status.idle":"2023-01-18T09:40:58.022819Z","shell.execute_reply.started":"2023-01-18T09:40:58.010430Z","shell.execute_reply":"2023-01-18T09:40:58.021956Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#checking if the number of labels is equal to number of filenames (imagenames)\nif len(labels)==len(filenames):\n    print (\"Numbers of records are equivalent to each other. Please Proceed\")\nelse:  \n    print (\"Number not matching. Criticial Error!\")","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.024082Z","iopub.execute_input":"2023-01-18T09:40:58.025045Z","iopub.status.idle":"2023-01-18T09:40:58.030877Z","shell.execute_reply.started":"2023-01-18T09:40:58.025012Z","shell.execute_reply":"2023-01-18T09:40:58.029842Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### What we need to do now is to convert every label/breed into a BOOLEAN array which means that It will only be true when the breed is same else everywhere it will be false.\nFor example - Lets say our label/breed is Border Coolie. An array will be created for border coolie and it will only be true/1 when the label will be border coolie elsewhere it will be false","metadata":{}},{"cell_type":"code","source":"#an example of the above explanation\nprint(labels[0])\nlabels[0]==unique_breeds\n","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.033307Z","iopub.execute_input":"2023-01-18T09:40:58.034182Z","iopub.status.idle":"2023-01-18T09:40:58.042989Z","shell.execute_reply.started":"2023-01-18T09:40:58.034148Z","shell.execute_reply":"2023-01-18T09:40:58.041998Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#We have to do this for every single breed\nboolean_labels=[label==np.array(unique_breeds) for label in labels] #this code says - do this task for every label in labels.\nboolean_labels[:3]","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.044458Z","iopub.execute_input":"2023-01-18T09:40:58.045618Z","iopub.status.idle":"2023-01-18T09:40:58.107059Z","shell.execute_reply.started":"2023-01-18T09:40:58.045583Z","shell.execute_reply":"2023-01-18T09:40:58.106246Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(boolean_labels)","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.108200Z","iopub.execute_input":"2023-01-18T09:40:58.108530Z","iopub.status.idle":"2023-01-18T09:40:58.114859Z","shell.execute_reply.started":"2023-01-18T09:40:58.108505Z","shell.execute_reply":"2023-01-18T09:40:58.113837Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"We have converted every single label into an array where it is only true where it matches its breed. it means every array of the label contains 120 elements (120 because we have total 120 breeds) and it is only True/1 at the element where it matches its breed","metadata":{}},{"cell_type":"markdown","source":"### Making a valdiation set using `test_train_split`. But using only 'n' amount of samples just so our whole data is effected incase of any wrong doings","metadata":{}},{"cell_type":"code","source":"x=filenames\ny=boolean_labels","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.116482Z","iopub.execute_input":"2023-01-18T09:40:58.117177Z","iopub.status.idle":"2023-01-18T09:40:58.121703Z","shell.execute_reply.started":"2023-01-18T09:40:58.117144Z","shell.execute_reply":"2023-01-18T09:40:58.120648Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"n_images=1000","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.123319Z","iopub.execute_input":"2023-01-18T09:40:58.123665Z","iopub.status.idle":"2023-01-18T09:40:58.130715Z","shell.execute_reply.started":"2023-01-18T09:40:58.123630Z","shell.execute_reply":"2023-01-18T09:40:58.129707Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#using train_test_split\nfrom sklearn.model_selection import train_test_split\nx_train,x_val,y_train,y_val=train_test_split(x[:n_images],y[:n_images],test_size=0.2, random_state=42)","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.132385Z","iopub.execute_input":"2023-01-18T09:40:58.132804Z","iopub.status.idle":"2023-01-18T09:40:58.141338Z","shell.execute_reply.started":"2023-01-18T09:40:58.132772Z","shell.execute_reply":"2023-01-18T09:40:58.140366Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(x_train),len(y_train),len(x_val),len(y_val)","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.142937Z","iopub.execute_input":"2023-01-18T09:40:58.143436Z","iopub.status.idle":"2023-01-18T09:40:58.150843Z","shell.execute_reply.started":"2023-01-18T09:40:58.143402Z","shell.execute_reply":"2023-01-18T09:40:58.149684Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train[:2],y_train[:2]","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.152270Z","iopub.execute_input":"2023-01-18T09:40:58.152994Z","iopub.status.idle":"2023-01-18T09:40:58.161859Z","shell.execute_reply.started":"2023-01-18T09:40:58.152961Z","shell.execute_reply":"2023-01-18T09:40:58.160785Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Working with images. Converting images into tensors using `tf.constant`.\nTensors simply means an array of numbers/integers\n\n**The process of converting images into tensors -**\n* Take an image filepath as an input\n* Using tensorflow to read the path and store the image on that path into a variable called `image`\n* Turn `image` into tensors\n* Scale the `image` using tf.convert_image_dtype(`image`, data_type). This converts color channel values from 0-255 to 0-1\n* Resize the `image` to 244,244,3 (height, width and color i.e rbg)\n* returning the modified image.","metadata":{}},{"cell_type":"code","source":"from matplotlib.pyplot import imread #imread stands for image read\nimage=imread(filenames[3])\nimage","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.163194Z","iopub.execute_input":"2023-01-18T09:40:58.164108Z","iopub.status.idle":"2023-01-18T09:40:58.177511Z","shell.execute_reply.started":"2023-01-18T09:40:58.164073Z","shell.execute_reply":"2023-01-18T09:40:58.176635Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"##### The above is an array of image present at 3rd index in the list of filenames we have.","metadata":{}},{"cell_type":"code","source":"#Converting the array into tensors (an array that is recogonized by tensorflow and helps in learning patterns)\ntf.constant(image)","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.178587Z","iopub.execute_input":"2023-01-18T09:40:58.179495Z","iopub.status.idle":"2023-01-18T09:40:58.188033Z","shell.execute_reply.started":"2023-01-18T09:40:58.179461Z","shell.execute_reply":"2023-01-18T09:40:58.187184Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#making a fucnation that does all the above mentioned steps.\nimage_size=224\ndef convert_image(image_path):\n    \"\"\"\"\"\"\n    #This is a docString Always make it when u make a funcation.\n    #This funcation converts the image into tensors so that tensoflow can read and act upon it.\n    \"\"\"\"\"\"\n    #Reading a file \n    image=tf.io.read_file(image_path) #io means input output. This funcation in tf will read the file.\n    #Turning the jpeg image into tensors with 3 color channels\n    image=tf.image.decode_jpeg(image,channels=3)#passing in our `image` variable and no. of channels\n    # since the array contains images from 0-255 range. We have to convert them from 0-1 range. This is done for scaling and is called **NORMALIZATION**\n    image=tf.image.convert_image_dtype(image,tf.float32)\n    #resize the image size\n    image=tf.image.resize(image,size=[image_size,image_size]) #passing in the height and width of the image\n    \n    return image","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.195314Z","iopub.execute_input":"2023-01-18T09:40:58.196175Z","iopub.status.idle":"2023-01-18T09:40:58.201944Z","shell.execute_reply.started":"2023-01-18T09:40:58.196141Z","shell.execute_reply":"2023-01-18T09:40:58.201186Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Making Data Batches for TensorFlow","metadata":{}},{"cell_type":"markdown","source":"TensorFlow likes to work on batches. Batches of image & label(something like - `(image,label)` pairs. In one batch it is suggested to have `32 pairs` (Suggested by father of CNN Yann Lecun)because to utilize he GPU in an optimum manner. It's not like any batch greater than 32 is meaningless or will not work but more like 32 can work really work :)","metadata":{}},{"cell_type":"code","source":"#making a funcation that returns a tuple of (convert_image,label). \ndef get_image_label(image_path,label):\n    \"\"\"Returns a tuple of image that is processed along with it's label\"\"\"\n    image=convert_image(image_path)\n    return image,label","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.203146Z","iopub.execute_input":"2023-01-18T09:40:58.204158Z","iopub.status.idle":"2023-01-18T09:40:58.212345Z","shell.execute_reply.started":"2023-01-18T09:40:58.204123Z","shell.execute_reply":"2023-01-18T09:40:58.211423Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"get_image_label(x[31],tf.constant(y[31])) \n#used tf.constnat just to show that we can convert the y (i,e boolean label array) into tensors easily!","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.213905Z","iopub.execute_input":"2023-01-18T09:40:58.214699Z","iopub.status.idle":"2023-01-18T09:40:58.231457Z","shell.execute_reply.started":"2023-01-18T09:40:58.214665Z","shell.execute_reply":"2023-01-18T09:40:58.230514Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Turning Data into DataBatches of 32. We'll be using the above funcation `convert_image` for this purpose.\n\n* This funcation will shuffle the training set but won't shuffle the validation set.\n* The batches will be made out of pairs of x and y (filenames and boolean_labels). such as - `(x,y)`","metadata":{}},{"cell_type":"code","source":"BATCH_SIZE=32\ndef create_batches(x,y=None,batch_size=BATCH_SIZE,valid_data=False,test_data=False): \n    #the reason valid data and test data is false if because we can pass the set ourself and \n    #funcation will act accodingly. Example - if it will be test set then test_data will become true\n    \"\"\"\"\"\"\n    #this funcation converst the images and filenames i.e (x and y) into data batches so that \n    #tensorflow can process these data batches\n    \"\"\"\"\"\"\n    #working on test_data first\n    if test_data :\n        print(\"Please wait, working on Test Data batches...\")\n        \n        data=tf.data.Dataset.from_tensor_slices((tf.constant(x))) \n        #this conversts fielpaths into tensor dataset\n        \n        data_batch=data.map(convert_image).batch(BATCH_SIZE) \n        #this converts the abov `data` into databatches of specified batch size\n        return data_batch\n    elif valid_data :\n        print(\"Please wait, workign on Valid Set batches...\")\n        \n        data=tf.data.Dataset.from_tensor_slices((tf.constant(x),tf.constant(y))) #converts filenames and labels into tensors\n        \n        data_batch=data.map(get_image_label).batch(BATCH_SIZE) #conversts converted tensors into batches of 32\n        #using get_image_label funcation on this one because it converts both images and labels into tuples whereeas convert_image only converts images.\n        return data_batch\n    else:\n        print(\"Please wait, working on Training Data batches...\") #we need to shuffle the data for trainnig dataset as well\n        data=tf.data.Dataset.from_tensor_slices((tf.constant(x),tf.constant(y)))\n        #shuffle the data before mapping\n        \n        data=data.shuffle(buffer_size=len(x)) #using len(x) here bcs we need to shuffle the whole dataset\n        #if we use buffer_size=100, it will only shuffle first 100 samples.\n        \n        #now we are mapping the data and making a batch for them.\n        data_batch=data.map(get_image_label).batch(BATCH_SIZE)\n        \n        return data_batch","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.234489Z","iopub.execute_input":"2023-01-18T09:40:58.234728Z","iopub.status.idle":"2023-01-18T09:40:58.245362Z","shell.execute_reply.started":"2023-01-18T09:40:58.234706Z","shell.execute_reply":"2023-01-18T09:40:58.244388Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data=create_batches(x_train,y_train)\nval_data=create_batches(x_val,y_val,valid_data=True)","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.247015Z","iopub.execute_input":"2023-01-18T09:40:58.248001Z","iopub.status.idle":"2023-01-18T09:40:58.285706Z","shell.execute_reply.started":"2023-01-18T09:40:58.247961Z","shell.execute_reply":"2023-01-18T09:40:58.284697Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### We need to prepare inputs & outputs along with the URL of exisisting model that we're gonna use. We will get the baseline results from the transfer learning (i.e already exisitimg model) and then improve it.\n\n* INPUT SHAPE - Images in right dimensions, converted into tensors\n* OUTPUT SHAPE - Labels converted in Tensors \n* URL of the model that we want to use.\n\nWE ARE SIMPLY DEFINING THE INPUTS AND OUTPUTS FOR OUR MODEL. NOTHING TOO FANCY. IT IS DONE EVERYTIME (FOR EVERY NEURAL NETWORK PMODEL).","metadata":{}},{"cell_type":"code","source":"INPUT_SHAPE = [None,image_size,image_size,3] #it is the shape of the image. batch_size,height,width, color channels \n#(it is none cuz the data btch is 32 here whihch is default so it is marked as none.),\nOUTPUT_SHAPE=len(unique_breeds) #we want to have an array of 120 breeds where the correct breed will be marked as 1 and other as 0\n\n#we will use tensorflow Hub for using the tranfer learning\nMODEL_URL = \"https://tfhub.dev/google/imagenet/mobilenet_v2_130_224/classification/4\"","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.288706Z","iopub.execute_input":"2023-01-18T09:40:58.289326Z","iopub.status.idle":"2023-01-18T09:40:58.294167Z","shell.execute_reply.started":"2023-01-18T09:40:58.289292Z","shell.execute_reply":"2023-01-18T09:40:58.293222Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Keras has 3 steps for model -\n* Model Instantion - where we set inputs and dense layer\n* Model Compiling - where we compile the model \n* Buid - Where we build the model\n","metadata":{}},{"cell_type":"code","source":"# Step -1 \ndef create_model(input_shape=INPUT_SHAPE, output_shape=OUTPUT_SHAPE, model_url=MODEL_URL):\n    print (f\"Building a model with {MODEL_URL} model\")\n    model=tf.keras.Sequential([\n        hub.KerasLayer(MODEL_URL),#input layer\n        tf.keras.layers.Dense(units=OUTPUT_SHAPE,#setting up the dense layer \n                              activation=\"softmax\") #output layer\n    ])\n    \n\n    #Step-2\n    model.compile(loss=tf.keras.losses.CategoricalCrossentropy(),\n                  optimizer=tf.keras.optimizers.Adam(),\n                  metrics=['accuracy'])\n\n    #Step-3\n    model.build(INPUT_SHAPE)\n    \n    return (model)","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.295487Z","iopub.execute_input":"2023-01-18T09:40:58.296736Z","iopub.status.idle":"2023-01-18T09:40:58.304392Z","shell.execute_reply.started":"2023-01-18T09:40:58.296699Z","shell.execute_reply":"2023-01-18T09:40:58.303505Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model=create_model()\nmodel.summary()","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:58.305680Z","iopub.execute_input":"2023-01-18T09:40:58.306569Z","iopub.status.idle":"2023-01-18T09:40:59.679443Z","shell.execute_reply.started":"2023-01-18T09:40:58.306534Z","shell.execute_reply":"2023-01-18T09:40:59.678422Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### In the above output the \"keras_layer_2\" is the patterns learnt by mobilenet by training on ImageNet (a big databse of images)\n### \"denser_2\" is the patterns learnt in dataset we've provided.","metadata":{}},{"cell_type":"markdown","source":"## Creating Callbacks\n\nCallbacks are th helper funcations that can provide small little funcations such as - saving the model's progress, check the model's progress or stop the process if the model stops imrpoving","metadata":{"execution":{"iopub.status.busy":"2022-12-27T10:13:55.129652Z","iopub.execute_input":"2022-12-27T10:13:55.130406Z","iopub.status.idle":"2022-12-27T10:13:55.148077Z","shell.execute_reply.started":"2022-12-27T10:13:55.130313Z","shell.execute_reply":"2022-12-27T10:13:55.147221Z"}}},{"cell_type":"markdown","source":"### Tensorbaord has 3 steps -\n* Load the tensorbaord extension\n* Create a callback that is able to save logs while model is training\n* Visulize logs with '%tensorbard' magic funcation.","metadata":{}},{"cell_type":"markdown","source":"### Loading Tensorboard Extension","metadata":{"execution":{"iopub.status.busy":"2022-12-28T10:10:29.361337Z","iopub.execute_input":"2022-12-28T10:10:29.361739Z","iopub.status.idle":"2022-12-28T10:10:29.367259Z","shell.execute_reply.started":"2022-12-28T10:10:29.361706Z","shell.execute_reply":"2022-12-28T10:10:29.366142Z"}}},{"cell_type":"code","source":"%load_ext tensorboard\nimport datetime\ndef create_tensorboard_callback():\n    log_dir=\"logs/fit/\" + datetime.datetime.now().strftime(\"%Y%m%d-%H%M%S\") #saving logs file in the log directory (alrady present in Kaggle) and \n    #having the current time. strftime returns string formatted in datetime format and %y%m%d stands for year month day hour min second\n    return tf.keras.callbacks.TensorBoard(log_dir=log_dir)","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:59.681010Z","iopub.execute_input":"2023-01-18T09:40:59.681659Z","iopub.status.idle":"2023-01-18T09:40:59.689480Z","shell.execute_reply.started":"2023-01-18T09:40:59.681620Z","shell.execute_reply":"2023-01-18T09:40:59.688358Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Making a callback for early stopping\n\nEarly stopping is used for making the process stop if it stops improving in order to ensure `overfitting` doesnt happen","metadata":{}},{"cell_type":"code","source":"early_stopping=tf.keras.callbacks.EarlyStopping(patience=3,\n                                               monitor=\"val_accuracy\")","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:59.691521Z","iopub.execute_input":"2023-01-18T09:40:59.691932Z","iopub.status.idle":"2023-01-18T09:40:59.697999Z","shell.execute_reply.started":"2023-01-18T09:40:59.691897Z","shell.execute_reply":"2023-01-18T09:40:59.697108Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Checking if the GPU is working or not\nprint (\"Yessir, GPU is working!!\") if tf.config.list_physical_devices(\"GPU\")else \"Not working! Not workin!\"","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:59.699548Z","iopub.execute_input":"2023-01-18T09:40:59.699937Z","iopub.status.idle":"2023-01-18T09:40:59.708467Z","shell.execute_reply.started":"2023-01-18T09:40:59.699904Z","shell.execute_reply":"2023-01-18T09:40:59.707482Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"NUM_EPOCHS=100 #Epochs are the passes that the model goe thru to learn patterns in the images/data","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:59.709796Z","iopub.execute_input":"2023-01-18T09:40:59.710294Z","iopub.status.idle":"2023-01-18T09:40:59.717821Z","shell.execute_reply.started":"2023-01-18T09:40:59.710259Z","shell.execute_reply":"2023-01-18T09:40:59.716875Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Creating a funcation for training the model\n* Create a model using `create_model()`\n* Create tensoboard callback using `create_tensorboard_callback()`\n* Call the `model.fit()` with suitable arguments ","metadata":{}},{"cell_type":"code","source":"def train_model():\n    #creating a model\n    model=create_model()\n    \n    #calling tensorboard\n    #tensorboard=create_tensorboard_callback()\n    \n    #calling mode.fit on training data (i.e 1000 images) cuz we need to train on small amount of data first\n    model.fit(x=train_data,\n             epochs=NUM_EPOCHS,\n             validation_data=val_data,\n             validation_freq=1,#cehcks validation metrics every epoch\n             callbacks=[early_stopping])\n    return model\n    \n    ","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:59.719438Z","iopub.execute_input":"2023-01-18T09:40:59.719830Z","iopub.status.idle":"2023-01-18T09:40:59.730846Z","shell.execute_reply.started":"2023-01-18T09:40:59.719736Z","shell.execute_reply":"2023-01-18T09:40:59.729901Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model=train_model()","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:40:59.732452Z","iopub.execute_input":"2023-01-18T09:40:59.732834Z","iopub.status.idle":"2023-01-18T09:42:07.055631Z","shell.execute_reply.started":"2023-01-18T09:40:59.732801Z","shell.execute_reply":"2023-01-18T09:42:07.054664Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Tensorboard isnt working on Kaggle so we'll let it go.","metadata":{}},{"cell_type":"markdown","source":"## Making predictions on the dataset\n\n* We will be using `m.predict()` funcation to predict the % of chances of a breed to be (similar to as of `predict.proba()`.\n\n* We will use `val_data` as our validation dataset to make predictios on","metadata":{}},{"cell_type":"code","source":"val_data","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:07.057470Z","iopub.execute_input":"2023-01-18T09:42:07.057869Z","iopub.status.idle":"2023-01-18T09:42:07.067222Z","shell.execute_reply.started":"2023-01-18T09:42:07.057831Z","shell.execute_reply":"2023-01-18T09:42:07.066098Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions=model.predict(val_data,verbose=1) \npredictions","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:07.068874Z","iopub.execute_input":"2023-01-18T09:42:07.069285Z","iopub.status.idle":"2023-01-18T09:42:08.120591Z","shell.execute_reply.started":"2023-01-18T09:42:07.069250Z","shell.execute_reply":"2023-01-18T09:42:08.119661Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(predictions)","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:08.122169Z","iopub.execute_input":"2023-01-18T09:42:08.122530Z","iopub.status.idle":"2023-01-18T09:42:08.129509Z","shell.execute_reply.started":"2023-01-18T09:42:08.122494Z","shell.execute_reply":"2023-01-18T09:42:08.128581Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Lenght of prediction array is 200 becuase there are 200 images in the val data array and each image has an array of 120 labels out of which max value is the corresponding breed ","metadata":{}},{"cell_type":"code","source":"predictions[9] \nlen(predictions[9])","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:08.130929Z","iopub.execute_input":"2023-01-18T09:42:08.131573Z","iopub.status.idle":"2023-01-18T09:42:08.142328Z","shell.execute_reply.started":"2023-01-18T09:42:08.131537Z","shell.execute_reply":"2023-01-18T09:42:08.140637Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"See the array at predictions[9] contains 120 labels and each label corresponds to a breed (as in `unque_breeds`)","metadata":{}},{"cell_type":"markdown","source":"### Fetching the breed of an array (prediction)","metadata":{}},{"cell_type":"code","source":"print(predictions[3])\nprint (f\"Length of prediction on the 3rd image : {len(predictions[3])}\")\nprint (f\"Highest value in the array of predictions of 3rd image : {np.max(predictions[3])}\")\nprint (f\"Index of highest value is :{np.argmax(predictions[3])}\")\nprint (f\"Breed at corresponding highest index is : {unique_breeds[np.argmax(predictions[3])]}\")","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:08.143570Z","iopub.execute_input":"2023-01-18T09:42:08.143989Z","iopub.status.idle":"2023-01-18T09:42:08.152907Z","shell.execute_reply.started":"2023-01-18T09:42:08.143956Z","shell.execute_reply":"2023-01-18T09:42:08.151765Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**The code above is used for checking the highest value in the array and then checking the same index we've got for highest value in the unique_breeds array.**","metadata":{}},{"cell_type":"code","source":"print (predictions[33])\nprint (f\" Lenght of 3rd prediction (array) is : {len(predictions[33])}\")\nprint (f\" Highest Value in the 3rd prediction is : {np.max(predictions[33])}\")\nprint (f\" Index of highest value is : {np.argmax(predictions[33])}\")\nprint (f\" Predicted breed is : {unique_breeds[np.argmax(predictions[33])]}\")","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:08.154053Z","iopub.execute_input":"2023-01-18T09:42:08.154418Z","iopub.status.idle":"2023-01-18T09:42:08.164957Z","shell.execute_reply.started":"2023-01-18T09:42:08.154384Z","shell.execute_reply":"2023-01-18T09:42:08.163980Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#makign a concise funcation for the above code so it can be reused\n\ndef predict_breed(index):\n    print (f\"The chosen Index is : {index}\")\n    print (f\"Highest value in the prediction is : {np.max(predictions[index])}\")\n    print (f\"Index of highest valye is : {np.argmax(predictions[index])}\")\n    print (f\"Predicted Breed is : {unique_breeds[np.argmax(predictions[index])]}\")","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:08.167078Z","iopub.execute_input":"2023-01-18T09:42:08.167829Z","iopub.status.idle":"2023-01-18T09:42:08.174120Z","shell.execute_reply.started":"2023-01-18T09:42:08.167749Z","shell.execute_reply":"2023-01-18T09:42:08.173137Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predict_breed(42)","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:08.175694Z","iopub.execute_input":"2023-01-18T09:42:08.176408Z","iopub.status.idle":"2023-01-18T09:42:08.184804Z","shell.execute_reply.started":"2023-01-18T09:42:08.176373Z","shell.execute_reply":"2023-01-18T09:42:08.183649Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Making a funcation that will simpply return the breed whenever we pass an image `predictions` index.","metadata":{}},{"cell_type":"code","source":"def get_pred_label(index):\n    return unique_breeds[np.argmax(index)]\n\nget_pred_label(predictions[81])","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:08.186354Z","iopub.execute_input":"2023-01-18T09:42:08.187031Z","iopub.status.idle":"2023-01-18T09:42:08.196645Z","shell.execute_reply.started":"2023-01-18T09:42:08.186997Z","shell.execute_reply":"2023-01-18T09:42:08.195643Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"We need to unbatchify the validation data so could commpare the preds with true labels. What we havwe currently is labels and images. We will unbatchify labels into a seprate list and images (that are in form of array) in seprate list using `.unbatch()` and `as_numpy_iterator`. What `as_numpy_iterator` do is it converts the unbatched items in form of a iterable (list)","metadata":{}},{"cell_type":"code","source":"\ndef unbatchify_data(data):\n    images=[]\n    labels=[]\n    \n    for image, label in data.unbatch().as_numpy_iterator():\n    \n        images.append(image)\n        labels.append(unique_breeds[np.argmax(label)])\n    return images,labels\n\n#we can pass it any data and it will unbatchify it.","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:08.198030Z","iopub.execute_input":"2023-01-18T09:42:08.198751Z","iopub.status.idle":"2023-01-18T09:42:08.206200Z","shell.execute_reply.started":"2023-01-18T09:42:08.198712Z","shell.execute_reply":"2023-01-18T09:42:08.205177Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#testing the unbatchify funcation\nval_images, val_labels = unbatchify_data(val_data)","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:08.208073Z","iopub.execute_input":"2023-01-18T09:42:08.208962Z","iopub.status.idle":"2023-01-18T09:42:08.788262Z","shell.execute_reply.started":"2023-01-18T09:42:08.208928Z","shell.execute_reply":"2023-01-18T09:42:08.787269Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"val_images[20], val_labels[20], unique_breeds[20]","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:08.790298Z","iopub.execute_input":"2023-01-18T09:42:08.790663Z","iopub.status.idle":"2023-01-18T09:42:08.800596Z","shell.execute_reply.started":"2023-01-18T09:42:08.790629Z","shell.execute_reply":"2023-01-18T09:42:08.799448Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Making a funcation that will potray the predicted output alongwith true output and the image as well","metadata":{}},{"cell_type":"code","source":"def show_preds(prediction_proba, labels, images ,n=3):\n    pred_prob, true_label, image = prediction_proba[n],labels[n],images[n]\n    \n    #predicting the label of the array passed in (i.e `n`)\n    pred_label = get_pred_label(pred_prob)\n    \n    #plotting the image of the nth Index\n    plt.imshow(image)\n    \n    ## removing xticks and yticks\n    plt.xticks([])\n    plt.yticks([])\n    color1='green'\n    color2='red'\n    \n    #title \n    if pred_label==true_label:\n        plt.title(f\" Yaay! Breeds Matched \\n Detected dog breed is {pred_label}. \\nConfidence percentage is {np.max(pred_prob)*100:2.0f}% \\nTrue label is {true_label}\",color=color1,family='monospace')\n    else :   \n        plt.title(f\" Looks like I got it wrong! \\n Detected dog breed is {pred_label}. \\nConfidence percentage is {np.max(pred_prob)*100:2.0f}% \\nTrue label is {true_label}\",color=color2,family='monospace')\n        \n        \n              \n    ","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:08.802404Z","iopub.execute_input":"2023-01-18T09:42:08.802960Z","iopub.status.idle":"2023-01-18T09:42:08.811828Z","shell.execute_reply.started":"2023-01-18T09:42:08.802918Z","shell.execute_reply":"2023-01-18T09:42:08.810793Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"show_preds(prediction_proba=predictions,\n         labels=val_labels,\n         images=val_images,n=98)","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:08.813558Z","iopub.execute_input":"2023-01-18T09:42:08.813954Z","iopub.status.idle":"2023-01-18T09:42:08.964554Z","shell.execute_reply.started":"2023-01-18T09:42:08.813918Z","shell.execute_reply":"2023-01-18T09:42:08.963602Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import ConfusionMatrixDisplay, confusion_matrix","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:08.965959Z","iopub.execute_input":"2023-01-18T09:42:08.966554Z","iopub.status.idle":"2023-01-18T09:42:08.972194Z","shell.execute_reply.started":"2023-01-18T09:42:08.966521Z","shell.execute_reply":"2023-01-18T09:42:08.970853Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"complete_data=create_batches(x,y)","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:08.974023Z","iopub.execute_input":"2023-01-18T09:42:08.974452Z","iopub.status.idle":"2023-01-18T09:42:09.065531Z","shell.execute_reply.started":"2023-01-18T09:42:08.974418Z","shell.execute_reply":"2023-01-18T09:42:09.064562Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"full_model=create_model()","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:09.067286Z","iopub.execute_input":"2023-01-18T09:42:09.067690Z","iopub.status.idle":"2023-01-18T09:42:10.433023Z","shell.execute_reply.started":"2023-01-18T09:42:09.067655Z","shell.execute_reply":"2023-01-18T09:42:10.432099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_model_callback=tf.keras.callbacks.EarlyStopping(monitor='accuracy',patience=3)\nfull_model.fit(x=complete_data,\n             epochs=NUM_EPOCHS,\n             callbacks=[final_model_callback])","metadata":{"execution":{"iopub.status.busy":"2023-01-18T09:42:10.434634Z","iopub.execute_input":"2023-01-18T09:42:10.435099Z","iopub.status.idle":"2023-01-18T09:49:34.379941Z","shell.execute_reply.started":"2023-01-18T09:42:10.435058Z","shell.execute_reply":"2023-01-18T09:49:34.379253Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\ntest_path='/kaggle/input/dog-breed-identification/test'\ntest_filenames=[test_path+fname for fname in os.listdir(test_path)]\ntest_filenames[:1]\n#Image.open('/kaggle/input/dog-breed-identification/test/000621fb3cbb32d8935728e48679680e.jpg')","metadata":{"execution":{"iopub.status.busy":"2023-01-18T10:39:19.486697Z","iopub.execute_input":"2023-01-18T10:39:19.487964Z","iopub.status.idle":"2023-01-18T10:39:19.503150Z","shell.execute_reply.started":"2023-01-18T10:39:19.487912Z","shell.execute_reply":"2023-01-18T10:39:19.501976Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(test_filenames)","metadata":{"execution":{"iopub.status.busy":"2023-01-18T11:28:01.622157Z","iopub.execute_input":"2023-01-18T11:28:01.622857Z","iopub.status.idle":"2023-01-18T11:28:01.629632Z","shell.execute_reply.started":"2023-01-18T11:28:01.622820Z","shell.execute_reply":"2023-01-18T11:28:01.628547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"test_batch=create_batches(test_filenames,test_data=True)","metadata":{"execution":{"iopub.status.busy":"2023-01-18T11:28:04.821549Z","iopub.execute_input":"2023-01-18T11:28:04.821908Z","iopub.status.idle":"2023-01-18T11:28:04.844432Z","shell.execute_reply.started":"2023-01-18T11:28:04.821876Z","shell.execute_reply":"2023-01-18T11:28:04.843362Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"test_batch","metadata":{"execution":{"iopub.status.busy":"2023-01-18T11:28:08.512974Z","iopub.execute_input":"2023-01-18T11:28:08.513361Z","iopub.status.idle":"2023-01-18T11:28:08.520055Z","shell.execute_reply.started":"2023-01-18T11:28:08.513328Z","shell.execute_reply":"2023-01-18T11:28:08.518925Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#test_predictions=full_model.predict(test_batch, verbose=1)","metadata":{"execution":{"iopub.status.busy":"2023-01-18T11:28:12.634183Z","iopub.execute_input":"2023-01-18T11:28:12.634569Z","iopub.status.idle":"2023-01-18T11:28:12.692184Z","shell.execute_reply.started":"2023-01-18T11:28:12.634539Z","shell.execute_reply":"2023-01-18T11:28:12.690768Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"execution":{"iopub.status.busy":"2023-01-18T11:28:53.190946Z","iopub.execute_input":"2023-01-18T11:28:53.191367Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}