{"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        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":"2023-10-24T13:20:32.95865Z","iopub.execute_input":"2023-10-24T13:20:32.959534Z","iopub.status.idle":"2023-10-24T13:20:32.980157Z","shell.execute_reply.started":"2023-10-24T13:20:32.959489Z","shell.execute_reply":"2023-10-24T13:20:32.979261Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install -q hvplot","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:20:33.021617Z","iopub.execute_input":"2023-10-24T13:20:33.021982Z","iopub.status.idle":"2023-10-24T13:20:45.357378Z","shell.execute_reply.started":"2023-10-24T13:20:33.021952Z","shell.execute_reply":"2023-10-24T13:20:45.355814Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 📦Import All Libraries","metadata":{}},{"cell_type":"code","source":"import hvplot.pandas\nfrom skimage import io\nimport matplotlib.pyplot as plt\n\n\nfrom skimage import io\nfrom sklearn.preprocessing import LabelEncoder\nfrom sklearn.model_selection import train_test_split\nfrom tqdm import tqdm\nimport cv2\n\n\nimport tensorflow as tf\nfrom tensorflow.keras import layers, regularizers\nfrom tensorflow.keras.layers import Input, Conv2D, MaxPooling2D, Flatten, Dense, BatchNormalization, Dropout, GlobalAveragePooling2D\nfrom tensorflow.keras.regularizers import l2\n\n\nimport random","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:20:45.359818Z","iopub.execute_input":"2023-10-24T13:20:45.360191Z","iopub.status.idle":"2023-10-24T13:20:45.369431Z","shell.execute_reply.started":"2023-10-24T13:20:45.360159Z","shell.execute_reply":"2023-10-24T13:20:45.368178Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tf.config.experimental_run_functions_eagerly(True)","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:20:45.370478Z","iopub.execute_input":"2023-10-24T13:20:45.370972Z","iopub.status.idle":"2023-10-24T13:20:45.382531Z","shell.execute_reply.started":"2023-10-24T13:20:45.370944Z","shell.execute_reply":"2023-10-24T13:20:45.381518Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission = pd.read_csv(\"/kaggle/input/UBC-OCEAN/sample_submission.csv\")\ntrain = pd.read_csv(\"/kaggle/input/UBC-OCEAN/train.csv\")\ntest = pd.read_csv(\"/kaggle/input/UBC-OCEAN/test.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:20:45.384898Z","iopub.execute_input":"2023-10-24T13:20:45.385205Z","iopub.status.idle":"2023-10-24T13:20:45.406601Z","shell.execute_reply.started":"2023-10-24T13:20:45.38518Z","shell.execute_reply":"2023-10-24T13:20:45.405787Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head(10)","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:20:45.407799Z","iopub.execute_input":"2023-10-24T13:20:45.408125Z","iopub.status.idle":"2023-10-24T13:20:45.421229Z","shell.execute_reply.started":"2023-10-24T13:20:45.408099Z","shell.execute_reply":"2023-10-24T13:20:45.420285Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.label.unique(), train.image_width.unique(),  train.image_height.unique()","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:20:45.422563Z","iopub.execute_input":"2023-10-24T13:20:45.422889Z","iopub.status.idle":"2023-10-24T13:20:45.439896Z","shell.execute_reply.started":"2023-10-24T13:20:45.422832Z","shell.execute_reply":"2023-10-24T13:20:45.438831Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.info()","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:20:45.441318Z","iopub.execute_input":"2023-10-24T13:20:45.442195Z","iopub.status.idle":"2023-10-24T13:20:45.453774Z","shell.execute_reply.started":"2023-10-24T13:20:45.442168Z","shell.execute_reply":"2023-10-24T13:20:45.452808Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:20:45.454789Z","iopub.execute_input":"2023-10-24T13:20:45.455104Z","iopub.status.idle":"2023-10-24T13:20:45.469201Z","shell.execute_reply.started":"2023-10-24T13:20:45.455069Z","shell.execute_reply":"2023-10-24T13:20:45.468322Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.label.unique()","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:20:45.470731Z","iopub.execute_input":"2023-10-24T13:20:45.471027Z","iopub.status.idle":"2023-10-24T13:20:45.481445Z","shell.execute_reply.started":"2023-10-24T13:20:45.471002Z","shell.execute_reply":"2023-10-24T13:20:45.480565Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"csv_file_path = '/kaggle/input/UBC-OCEAN/train.csv'\nbase_image_dir = '/kaggle/input/UBC-OCEAN/train_images/'\nbase_thumbnail_dir = '/kaggle/input/UBC-OCEAN/train_thumbnails/'\n\nmeta_data = pd.read_csv(csv_file_path)\nmeta_data['path'] = base_image_dir + train['image_id'].astype(str) + '.png'\nmeta_data['path_thumb'] = base_thumbnail_dir + train['image_id'].astype(str) + '_thumbnail.png'\nmeta_data.head()","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:20:45.485118Z","iopub.execute_input":"2023-10-24T13:20:45.485394Z","iopub.status.idle":"2023-10-24T13:20:45.508058Z","shell.execute_reply.started":"2023-10-24T13:20:45.48537Z","shell.execute_reply":"2023-10-24T13:20:45.507077Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 📊Visualization","metadata":{}},{"cell_type":"code","source":"labels = ['HGSC', 'LGSC', 'EC', 'CC', 'MC', \"Other\"]\nfig, axs = plt.subplots(len(labels), 5, figsize=(10, 10))\n\n# Veri çerçevesini kullanarak gerekli bilgileri alın\nfor i, lab in enumerate(labels):\n    imgs_with_label = meta_data[(meta_data['label'] == lab) & (meta_data['is_tma'] == True)]\n    img_paths = imgs_with_label['path']\n    \n    for j, img_path in enumerate(img_paths):\n        ax = axs[i, j]\n        try:\n            img = io.imread(img_path)\n            ax.imshow(img, interpolation='bilinear')\n            \n            img_id = os.path.splitext(os.path.basename(img_path))[0]\n            is_tma_status = 'True' if imgs_with_label['is_tma'].values[j] else 'False'\n            \n            ax.set_title(f'Image ID: {img_id}\\nLabel: {lab}\\nIs TMA: {is_tma_status}', fontsize=9)\n            ax.axis('off')\n        except FileNotFoundError:\n            print(f'Thumbnail at path \"{img_path}\" does not exist.')\n\nfor ax in axs.flatten():\n    ax.set_aspect('auto')\n\nplt.tight_layout()\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:20:45.509181Z","iopub.execute_input":"2023-10-24T13:20:45.509478Z","iopub.status.idle":"2023-10-24T13:21:19.105338Z","shell.execute_reply.started":"2023-10-24T13:20:45.509451Z","shell.execute_reply":"2023-10-24T13:21:19.10317Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"label_encoder = LabelEncoder()\nmeta_data['label'] = label_encoder.fit_transform(train['label'])","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:21:19.106858Z","iopub.execute_input":"2023-10-24T13:21:19.107197Z","iopub.status.idle":"2023-10-24T13:21:19.11465Z","shell.execute_reply.started":"2023-10-24T13:21:19.107166Z","shell.execute_reply":"2023-10-24T13:21:19.112866Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"meta_data['image_id']=meta_data['image_id'].astype(\"float32\")\nmeta_data['label']=meta_data['label'].astype(\"float32\")\nmeta_data['image_width']=meta_data['image_width'].astype(\"float32\")\nmeta_data['image_height']=meta_data['image_height'].astype(\"float32\")","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:21:19.115598Z","iopub.execute_input":"2023-10-24T13:21:19.115969Z","iopub.status.idle":"2023-10-24T13:21:19.129694Z","shell.execute_reply.started":"2023-10-24T13:21:19.115936Z","shell.execute_reply":"2023-10-24T13:21:19.128783Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Grouping by 'label' and counting based on 'is_tma'\ngrouped_by_label_and_tma = train.groupby('label')['is_tma'].value_counts().unstack().fillna(0)\n\n# Sorting the data by frequency\nsorted_indexes_by_frequency = np.argsort(grouped_by_label_and_tma.sum(axis=1).values)[::-1]\nsorted_grouped_data = grouped_by_label_and_tma.iloc[sorted_indexes_by_frequency]\n\n# Visualizing using hvplot\nplot = sorted_grouped_data.hvplot.bar(stacked=True, width=800, height=500, rot=45, title=\"Distribution of is_tma by Label\")\n\n# Adjusting the plot settings\nplot.opts(legend_position='top_left', xlabel='Label', ylabel='Frequency')\n\n# Displaying the plot\nplot\n","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:21:19.131125Z","iopub.execute_input":"2023-10-24T13:21:19.131741Z","iopub.status.idle":"2023-10-24T13:21:19.397317Z","shell.execute_reply.started":"2023-10-24T13:21:19.131708Z","shell.execute_reply":"2023-10-24T13:21:19.396314Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.describe().drop(\"image_id\", axis=1)","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:21:19.398782Z","iopub.execute_input":"2023-10-24T13:21:19.39912Z","iopub.status.idle":"2023-10-24T13:21:19.420058Z","shell.execute_reply.started":"2023-10-24T13:21:19.399075Z","shell.execute_reply":"2023-10-24T13:21:19.419229Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Grouping by 'label' and counting based on 'is_tma' values\ngrouped_by_label = meta_data.groupby('label')['is_tma'].value_counts().unstack().fillna(0)\n\n# Calculating total occurrences for each 'label'\ngrouped_by_label['Total'] = grouped_by_label[True] + grouped_by_label[False]\n\n# Calculating the percentage of True and False 'is_tma' values for each 'label'\ngrouped_by_label['Percent_True'] = (grouped_by_label[True] / grouped_by_label['Total']) * 100\ngrouped_by_label['Percent_False'] = (grouped_by_label[False] / grouped_by_label['Total']) * 100\n\n# Displaying the results\nprint(grouped_by_label)","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:21:19.421156Z","iopub.execute_input":"2023-10-24T13:21:19.421421Z","iopub.status.idle":"2023-10-24T13:21:19.436894Z","shell.execute_reply.started":"2023-10-24T13:21:19.421397Z","shell.execute_reply":"2023-10-24T13:21:19.435915Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 🛠️Pre-Processing","metadata":{}},{"cell_type":"code","source":"meta_data = meta_data[meta_data['is_tma'] == False]","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:21:19.438086Z","iopub.execute_input":"2023-10-24T13:21:19.438448Z","iopub.status.idle":"2023-10-24T13:21:19.444727Z","shell.execute_reply.started":"2023-10-24T13:21:19.438412Z","shell.execute_reply":"2023-10-24T13:21:19.443889Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"meta_data.head()","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:21:19.446104Z","iopub.execute_input":"2023-10-24T13:21:19.447114Z","iopub.status.idle":"2023-10-24T13:21:19.466122Z","shell.execute_reply.started":"2023-10-24T13:21:19.447077Z","shell.execute_reply":"2023-10-24T13:21:19.465185Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 📈Generating Data","metadata":{}},{"cell_type":"code","source":"def flip_left_right(img):\n    return tf.image.flip_left_right(img)\n\ndef flip_up_down(img):\n    return tf.image.flip_up_down(img)\n\ndef rotate_right_45(img):\n    return tf.image.rot90(img, k=1)\n\ndef rotate_left_45(img):\n    return tf.image.rot90(img, k=-1)\n\ndef adjust_brightness(img):\n    return tf.image.adjust_brightness(img, 0.25)\n\ndef darken_image(img):\n    return tf.image.adjust_brightness(img, -0.25)\n\ndef adjust_contrast_high(img):\n    return tf.image.adjust_contrast(img, 1.25)\n\ndef adjust_contrast_low(img):\n    return tf.image.adjust_contrast(img, 0.75)","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:21:19.467317Z","iopub.execute_input":"2023-10-24T13:21:19.467552Z","iopub.status.idle":"2023-10-24T13:21:19.478606Z","shell.execute_reply.started":"2023-10-24T13:21:19.467531Z","shell.execute_reply":"2023-10-24T13:21:19.477898Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"@tf.function\ndef slice_image(image, slice_size=224, black_threshold=0.20):\n    shape = tf.shape(image)\n    height = shape[0]\n    width = shape[1]\n    \n    # Define the placeholder tensor for black slices\n    placeholder = tf.zeros([slice_size, slice_size, 3], dtype=tf.uint8)\n\n    def slice_at_position(i, j):\n        slice_ = image[i:i + slice_size, j:j + slice_size, :]\n        \n        # Calculate black pixel ratio\n        total_pixels = tf.cast(slice_size * slice_size, tf.float32)\n        black_pixels = tf.reduce_sum(tf.cast(tf.reduce_all(tf.equal(slice_, [0, 0, 0]), axis=-1), tf.float32))\n        black_ratio = black_pixels / total_pixels\n        \n        # Use tf.cond for conditional return to be compatible with graph mode\n        return tf.cond(black_ratio <= black_threshold,\n                       true_fn=lambda: slice_,\n                       false_fn=lambda: placeholder)\n\n    # Calculate all valid slice starting points\n    i_values = tf.range(0, height - slice_size + 1, slice_size)\n    j_values = tf.range(0, width - slice_size + 1, slice_size)\n    \n    # Generate the slices\n    slices = tf.map_fn(\n        lambda i: tf.map_fn(\n            lambda j: slice_at_position(i, j),\n            j_values,\n            dtype=tf.uint8\n        ),\n        i_values,\n        dtype=tf.uint8\n    )\n    \n    # Flatten the slices and filter out the black ones\n    slices = tf.reshape(slices, [-1, slice_size, slice_size, 3])\n    valid_slices_mask = tf.reduce_any(tf.reduce_any(slices != placeholder, axis=-1), axis=[1,2])\n    slices = tf.boolean_mask(slices, valid_slices_mask)\n    \n    return slices\n\n\n\ndef random_augmentations(image):\n    augmentations = [\n        flip_left_right,\n        flip_up_down,\n        rotate_right_45,\n        rotate_left_45,\n        adjust_brightness,\n        darken_image,\n        adjust_contrast_high,\n        adjust_contrast_low,\n    ]\n    \n    num_augmentations = random.randint(1, 3)\n    chosen_augmentations = random.sample(augmentations, num_augmentations)\n    \n    for augmentation in chosen_augmentations:\n        image = augmentation(image)\n    \n    return image\n@tf.function\ndef load_and_augment_image(image_path, label):\n    # Read the image\n    img = tf.io.read_file(image_path)\n    img = tf.image.decode_png(img, channels=3)\n    \n    # Slice the image (assuming slice_image returns a list of image slices)\n    slices = slice_image(img)\n    \n    # Augment each slice\n    augmented_slices = tf.map_fn(random_augmentations, slices, dtype=tf.uint8)\n    \n    # Repeat the label for each augmented slice\n    repeated_label = tf.repeat(label, tf.shape(augmented_slices)[0])\n    \n    return augmented_slices, repeated_label\n\n","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:35:17.340939Z","iopub.execute_input":"2023-10-24T13:35:17.341794Z","iopub.status.idle":"2023-10-24T13:35:17.356733Z","shell.execute_reply.started":"2023-10-24T13:35:17.341759Z","shell.execute_reply":"2023-10-24T13:35:17.355881Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"meta_data = meta_data.reset_index(drop=True)\nmeta_data = meta_data.reset_index(drop=True)\n\nimage_path = meta_data[\"path_thumb\"]\nlabel = meta_data[\"label\"]","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:27:09.925731Z","iopub.execute_input":"2023-10-24T13:27:09.926098Z","iopub.status.idle":"2023-10-24T13:27:09.933564Z","shell.execute_reply.started":"2023-10-24T13:27:09.926068Z","shell.execute_reply":"2023-10-24T13:27:09.932566Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\n\ndef visualize_slices(image_path):\n    img = tf.io.read_file(image_path)\n    img = tf.image.decode_png(img, channels=3)\n    slices = slice_image(img)\n    \n    plt.figure(figsize=(15, 15))\n    for i, slice_ in enumerate(slices, 1):\n        plt.subplot(5, 5, i)  # 5x5\n        plt.imshow(slice_)\n        plt.axis('off')\n        \n        if i == 25:\n            break\n    \n    plt.tight_layout()\n    plt.show()\n\n# Örnek bir resimle görselleştirme\nsample_image_path = image_path[12]\nvisualize_slices(sample_image_path)\n","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:35:20.586251Z","iopub.execute_input":"2023-10-24T13:35:20.586609Z","iopub.status.idle":"2023-10-24T13:35:22.656245Z","shell.execute_reply.started":"2023-10-24T13:35:20.586579Z","shell.execute_reply":"2023-10-24T13:35:22.655082Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### ➗Split Data For Train And Test","metadata":{}},{"cell_type":"code","source":"tf.data.experimental.enable_debug_mode()\ntf.config.experimental_run_functions_eagerly(True)","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:28:25.811104Z","iopub.execute_input":"2023-10-24T13:28:25.811482Z","iopub.status.idle":"2023-10-24T13:28:25.816367Z","shell.execute_reply.started":"2023-10-24T13:28:25.811453Z","shell.execute_reply":"2023-10-24T13:28:25.815401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def prepare_dataset(image_paths, labels):\n    dataset = tf.data.Dataset.from_tensor_slices((image_paths, labels))\n    dataset = dataset.map(load_and_augment_image, num_parallel_calls=tf.data.experimental.AUTOTUNE)\n    dataset = dataset.flat_map(lambda x, y: tf.data.Dataset.from_tensor_slices((x, y)))\n    dataset = dataset.batch(32).shuffle(buffer_size=1000).prefetch(tf.data.experimental.AUTOTUNE)\n    return dataset\n\nimage_paths_train, image_paths_test, labels_train, labels_test = train_test_split(\n    image_path, label, test_size=0.15, random_state=42)  # random_state, her seferinde aynı bölünmeyi almak için kullanılır\n\n# Eğitim ve test veri setlerini hazırlama\ntrain_dataset = prepare_dataset(image_paths_train, labels_train)\ntest_dataset = prepare_dataset(image_paths_test, labels_test)","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:35:26.137452Z","iopub.execute_input":"2023-10-24T13:35:26.138368Z","iopub.status.idle":"2023-10-24T13:35:26.557858Z","shell.execute_reply.started":"2023-10-24T13:35:26.138333Z","shell.execute_reply":"2023-10-24T13:35:26.557099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 📊Visualization-2-Train","metadata":{}},{"cell_type":"code","source":"# Fetch the first batch of data using the take method\nfor images_batch, labels_batch in train_dataset.take(1):\n    fig, axes = plt.subplots(1, 8, figsize=(20, 3))\n    \n    for i, ax in enumerate(axes):\n        ax.imshow(images_batch[i].numpy())\n        ax.set_title(str(labels_batch[i].numpy()))\n        ax.axis('off')\n    plt.show()\n","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:35:30.589007Z","iopub.execute_input":"2023-10-24T13:35:30.58934Z","iopub.status.idle":"2023-10-24T13:41:00.836788Z","shell.execute_reply.started":"2023-10-24T13:35:30.589314Z","shell.execute_reply":"2023-10-24T13:41:00.835745Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 📊Visualization-2-Test","metadata":{}},{"cell_type":"code","source":"# Fetch the first batch of data using the take method\nfor images_batch, labels_batch in test_dataset.take(1):\n    fig, axes = plt.subplots(1, 8, figsize=(20, 3))\n    \n    for i, ax in enumerate(axes):\n        ax.imshow(images_batch[i].numpy())\n        ax.set_title(str(labels_batch[i].numpy()))\n        ax.axis('off')\n    plt.show()\n","metadata":{"execution":{"iopub.status.busy":"2023-10-24T13:41:00.838672Z","iopub.execute_input":"2023-10-24T13:41:00.838992Z","iopub.status.idle":"2023-10-24T13:41:54.557402Z","shell.execute_reply.started":"2023-10-24T13:41:00.838961Z","shell.execute_reply":"2023-10-24T13:41:54.556518Z"},"trusted":true},"execution_count":null,"outputs":[]}]}