{"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":"Author : Aadya Aneesh Chinubhai \n\nKey Steps :\nBuild U-Net Class,\nDefine Activation function candidates,\nCompare Accuracy & Training time.","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport tensorflow as tf\nfrom tensorflow.keras import backend as K\nfrom tensorflow.keras.layers import Conv2D, MaxPooling2D, Dropout, Conv2DTranspose, concatenate\nfrom tensorflow.keras.models import Model\nfrom keras import metrics\nimport keras\nimport os\nimport random\nfrom tqdm import tqdm \nfrom zipfile import ZipFile\nfrom skimage.io import imread, imshow\nfrom skimage.transform import resize\nimport matplotlib.pyplot as plt\nimport pandas as pd","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:15:47.035103Z","iopub.execute_input":"2023-03-23T14:15:47.035664Z","iopub.status.idle":"2023-03-23T14:15:54.322113Z","shell.execute_reply.started":"2023-03-23T14:15:47.035616Z","shell.execute_reply":"2023-03-23T14:15:54.321080Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class UNet:\n    \n    def __init__(self, input_shape_,  activation_ = \"relu\"):\n        self.activation = activation_\n        self.input_shape = input_shape_\n    \n    def dice_coef(self, y_true, y_pred, smooth=100):\n        y_true = tf.cast(y_true, tf.float32)\n        y_pred = tf.cast(y_pred, tf.float32)\n        \n        y_true_f = K.flatten(y_true)\n        y_pred_f = K.flatten(y_pred)\n        intersection = K.sum(y_true_f * y_pred_f)\n        dice = (2. * intersection + smooth) / (K.sum(y_true_f) + K.sum(y_pred_f) + smooth)\n        return dice\n    \n    def dice_coef_loss(self, y_true, y_pred):\n        return -self.dice_coef(y_true, y_pred)\n    \n    def iou(self, y_true, y_pred):\n        y_true = tf.cast(y_true, tf.float32)\n        y_pred = tf.cast(y_pred, tf.float32)\n\n        def f(y_true, y_pred):\n            intersection = (y_true * y_pred).sum()\n            union = y_true.sum() + y_pred.sum() - intersection\n            x = (intersection + 1e-15) / (union + 1e-15)\n            x = x.astype(np.float32)\n            return x\n        \n        return tf.numpy_function(f, [y_true, y_pred], tf.float32)\n\n    def buildModel(self):\n        \n        # Lets create the DownSampling Blocks \n        kernel_initializer =  'he_uniform'\n         \n        inputs = tf.keras.Input(shape = self.input_shape)\n        \n        # Block - 1\n    \n        s = inputs\n\n        #Contraction path\n        c1 = Conv2D(16, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(s)\n#         c1 = Dropout(0.1)(c1)\n        c1 = Conv2D(16, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(c1)\n        p1 = MaxPooling2D((2, 2))(c1)\n\n        c2 = Conv2D(32, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(p1)\n#         c2 = Dropout(0.1)(c2)\n        c2 = Conv2D(32, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(c2)\n        p2 = MaxPooling2D((2, 2))(c2)\n\n        c3 = Conv2D(64, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(p2)\n#         c3 = Dropout(0.2)(c3)\n        c3 = Conv2D(64, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(c3)\n        p3 = MaxPooling2D((2, 2))(c3)\n\n        c4 = Conv2D(128, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(p3)\n#         c4 = Dropout(0.2)(c4)\n        c4 = Conv2D(128, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(c4)\n        p4 = MaxPooling2D(pool_size=(2, 2))(c4)\n\n        c5 = Conv2D(256, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(p4)\n#         c5 = Dropout(0.3)(c5)\n        c5 = Conv2D(256, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(c5)\n\n        #Expansive path \n        u6 = Conv2DTranspose(128, (2, 2), strides=(2, 2), padding='same')(c5)\n        u6 = concatenate([u6, c4])\n        c6 = Conv2D(128, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(u6)\n#         c6 = Dropout(0.2)(c6)\n        c6 = Conv2D(128, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(c6)\n\n        u7 = Conv2DTranspose(64, (2, 2), strides=(2, 2), padding='same')(c6)\n        u7 = concatenate([u7, c3])\n        c7 = Conv2D(64, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(u7)\n#         c7 = Dropout(0.2)(c7)\n        c7 = Conv2D(64, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(c7)\n\n        u8 = Conv2DTranspose(32, (2, 2), strides=(2, 2), padding='same')(c7)\n        u8 = concatenate([u8, c2])\n        c8 = Conv2D(32, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(u8)\n#         c8 = Dropout(0.1)(c8)\n        c8 = Conv2D(32, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(c8)\n\n        u9 = Conv2DTranspose(16, (2, 2), strides=(2, 2), padding='same')(c8)\n        u9 = concatenate([u9, c1])\n        c9 = Conv2D(16, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(u9)\n#         c9 = Dropout(0.1)(c9)\n        c9 = Conv2D(16, (3, 3), activation= self.activation, kernel_initializer=kernel_initializer, padding='same')(c9)\n\n        outputs = Conv2D(1, (1, 1), activation='sigmoid')(c9)\n\n        model = Model(inputs=[inputs], outputs=[outputs])\n        #compile model outside of this function to make it flexible. \n        model.summary()\n\n        return model\n \n    \n    def CompileandSummarize(self, model_):\n        model_.compile(optimizer = tf.keras.optimizers.Adam(), loss = self.dice_coef_loss, metrics = self.iou)","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:15:54.324274Z","iopub.execute_input":"2023-03-23T14:15:54.325003Z","iopub.status.idle":"2023-03-23T14:15:54.349759Z","shell.execute_reply.started":"2023-03-23T14:15:54.324959Z","shell.execute_reply":"2023-03-23T14:15:54.348817Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"'''Defining callbacks to calculate training time '''\n\nfrom timeit import default_timer as timer\n\nclass TimingCallback(keras.callbacks.Callback):\n    def __init__(self, logs={}):\n        self.logs=[]\n    def on_epoch_begin(self, epoch, logs={}):\n        self.starttime = timer()\n    def on_epoch_end(self, epoch, logs={}):\n        self.logs.append(timer()-self.starttime)\n","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:15:54.351164Z","iopub.execute_input":"2023-03-23T14:15:54.351729Z","iopub.status.idle":"2023-03-23T14:15:54.366857Z","shell.execute_reply.started":"2023-03-23T14:15:54.351692Z","shell.execute_reply":"2023-03-23T14:15:54.365778Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Now lets focus on preparing the data\n\nwith ZipFile(\"../input/data-science-bowl-2018/stage1_train.zip\",\"r\") as zip_ref:\n    zip_ref.extractall(\"./stage1_train\")\n    \nwith ZipFile(\"../input/data-science-bowl-2018/stage1_test.zip\",\"r\") as zip_ref:\n    zip_ref.extractall(\"./stage1_test\")    ","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:15:54.369705Z","iopub.execute_input":"2023-03-23T14:15:54.370076Z","iopub.status.idle":"2023-03-23T14:16:00.301481Z","shell.execute_reply.started":"2023-03-23T14:15:54.370031Z","shell.execute_reply":"2023-03-23T14:16:00.300445Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"seed = 42\nnp.random.seed = seed\n\nIMG_WIDTH = 96\nIMG_HEIGHT = 96\nIMG_CHANNELS = 3\n\nTRAIN_PATH = './stage1_train/'\nTEST_PATH = './stage1_test/'","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:16:00.303064Z","iopub.execute_input":"2023-03-23T14:16:00.303417Z","iopub.status.idle":"2023-03-23T14:16:00.309426Z","shell.execute_reply.started":"2023-03-23T14:16:00.303381Z","shell.execute_reply":"2023-03-23T14:16:00.308010Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_ids = next(os.walk(TRAIN_PATH))[1]\ntest_ids = next(os.walk(TEST_PATH))[1]\n\ntrain_ids[:5]","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:16:00.311102Z","iopub.execute_input":"2023-03-23T14:16:00.311770Z","iopub.status.idle":"2023-03-23T14:16:00.325484Z","shell.execute_reply.started":"2023-03-23T14:16:00.311733Z","shell.execute_reply":"2023-03-23T14:16:00.324567Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train = np.zeros((len(train_ids), IMG_HEIGHT, IMG_WIDTH, IMG_CHANNELS), dtype=np.uint8)\nY_train = np.zeros((len(train_ids), IMG_HEIGHT, IMG_WIDTH, 1), dtype=np.bool)\n\nprint('Resizing training images and masks')\nfor n, file_name in tqdm(enumerate(train_ids)):   \n    path = TRAIN_PATH + file_name\n    img = imread(path + '/images/' + file_name + '.png')[:,:,:IMG_CHANNELS]  \n    img = resize(img, (IMG_HEIGHT, IMG_WIDTH), mode='constant', preserve_range=True)\n    X_train[n] = img  #Fill empty X_train with values from img\n    mask = np.zeros((IMG_HEIGHT, IMG_WIDTH, 1), dtype=np.bool)\n    for mask_file in next(os.walk(path + '/masks/'))[2]:\n        mask_ = imread(path + '/masks/' + mask_file)\n        mask_ = np.expand_dims(resize(mask_, (IMG_HEIGHT, IMG_WIDTH), mode='constant',  \n                                      preserve_range=True), axis=-1)\n        mask = np.maximum(mask, mask_)  \n            \n    Y_train[n] = mask","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:16:00.326987Z","iopub.execute_input":"2023-03-23T14:16:00.327533Z","iopub.status.idle":"2023-03-23T14:20:42.194740Z","shell.execute_reply.started":"2023-03-23T14:16:00.327481Z","shell.execute_reply":"2023-03-23T14:20:42.193413Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# 5% Validation Images (34 Images)\nX_test, y_test  = X_train[636:], Y_train[636:]\nX_train, Y_train = X_train[0: 636], Y_train[0:636]","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:20:42.196840Z","iopub.execute_input":"2023-03-23T14:20:42.197255Z","iopub.status.idle":"2023-03-23T14:20:42.203337Z","shell.execute_reply.started":"2023-03-23T14:20:42.197214Z","shell.execute_reply":"2023-03-23T14:20:42.202207Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"(X_train.shape, Y_train.shape), (X_test.shape, y_test.shape)","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:20:42.204727Z","iopub.execute_input":"2023-03-23T14:20:42.208450Z","iopub.status.idle":"2023-03-23T14:20:42.217470Z","shell.execute_reply.started":"2023-03-23T14:20:42.208419Z","shell.execute_reply":"2023-03-23T14:20:42.216331Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_x = random.randint(0, 636)\nimshow(X_train[image_x])\nplt.show()\nimshow(np.squeeze(Y_train[image_x]))\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:20:42.222360Z","iopub.execute_input":"2023-03-23T14:20:42.222666Z","iopub.status.idle":"2023-03-23T14:20:42.678366Z","shell.execute_reply.started":"2023-03-23T14:20:42.222640Z","shell.execute_reply":"2023-03-23T14:20:42.672952Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class MexicanReLU(tf.keras.layers.Layer):\n    def __init__(self, alpha=1.0, sigma=1.0, mu=0.0):\n        super(MexicanReLU, self).__init__()\n        self.alpha = tf.Variable(alpha, trainable=True)\n        self.sigma = tf.Variable(sigma, trainable=True)\n        self.mu = tf.Variable(mu, trainable=True)\n\n    def call(self, inputs):\n        relu = tf.nn.relu(inputs)\n        gaussian = self.alpha * tf.exp(-tf.square(inputs - self.mu) / (2 * tf.square(self.sigma))) * (inputs - self.mu)\n        return relu + gaussian\n","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:30:41.712910Z","iopub.execute_input":"2023-03-23T14:30:41.713288Z","iopub.status.idle":"2023-03-23T14:30:41.723815Z","shell.execute_reply.started":"2023-03-23T14:30:41.713250Z","shell.execute_reply":"2023-03-23T14:30:41.721745Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# class SymmetricGaLU(tf.keras.layers.Layer):\n#     def __init__(self, **kwargs):\n#         super(SymmetricGaLU, self).__init__(**kwargs)\n\n#     def call(self, x):\n#         a, b = tf.split(x, 2, axis=-1)\n#         return tf.multiply(tf.nn.tanh(a), tf.nn.sigmoid(b))\n\n#     def get_config(self):\n#         config = super(SymmetricGaLU, self).get_config()\n#         return config\n\nclass Gelu(tf.keras.layers.Layer):\n    def __init__(self):\n        super(Gelu, self).__init__()\n\n    def call(self, inputs):\n        cdf = 0.5 * (1.0 + tf.math.erf(inputs / tf.sqrt(2.0)))\n        return inputs * cdf\n","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:20:42.680168Z","iopub.execute_input":"2023-03-23T14:20:42.680877Z","iopub.status.idle":"2023-03-23T14:20:42.688158Z","shell.execute_reply.started":"2023-03-23T14:20:42.680809Z","shell.execute_reply":"2023-03-23T14:20:42.686948Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class Swish(tf.keras.layers.Layer):\n    def __init__(self):\n        super(Swish, self).__init__()\n\n    def call(self, inputs):\n        return inputs * tf.keras.backend.sigmoid(inputs)\n","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:20:42.689857Z","iopub.execute_input":"2023-03-23T14:20:42.690717Z","iopub.status.idle":"2023-03-23T14:20:42.698328Z","shell.execute_reply.started":"2023-03-23T14:20:42.690675Z","shell.execute_reply":"2023-03-23T14:20:42.697247Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class TrainableLeakyReLU(tf.keras.layers.Layer):\n    def __init__(self, alpha_initializer=tf.initializers.constant(0.2), **kwargs):\n        super(TrainableLeakyReLU, self).__init__(**kwargs)\n        self.alpha_initializer = tf.keras.initializers.get(alpha_initializer)\n    \n    def build(self, input_shape):\n        self.alpha = self.add_weight(shape=(), initializer=self.alpha_initializer, trainable=True, name=\"alpha\")\n        super(TrainableLeakyReLU, self).build(input_shape)\n    \n    def call(self, inputs):\n        return tf.maximum(inputs, self.alpha * inputs)\n    \n    def get_config(self):\n        config = super(TrainableLeakyReLU, self).get_config()\n        config.update({\"alpha_initializer\": self.alpha_initializer})\n        return config","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:20:42.700940Z","iopub.execute_input":"2023-03-23T14:20:42.702467Z","iopub.status.idle":"2023-03-23T14:20:42.719136Z","shell.execute_reply.started":"2023-03-23T14:20:42.702430Z","shell.execute_reply":"2023-03-23T14:20:42.718099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class ISRU(tf.keras.layers.Layer):\n    def __init__(self, alpha=1.0, **kwargs):\n        super(ISRU, self).__init__(**kwargs)\n        self.alpha = tf.Variable(initial_value=alpha, trainable=True, name='alpha')\n\n    def call(self, inputs):\n        return inputs / tf.sqrt(1.0 + self.alpha * tf.square(inputs))\n","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:20:42.720664Z","iopub.execute_input":"2023-03-23T14:20:42.722739Z","iopub.status.idle":"2023-03-23T14:20:42.735039Z","shell.execute_reply.started":"2023-03-23T14:20:42.722700Z","shell.execute_reply":"2023-03-23T14:20:42.733927Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class Mish(tf.keras.layers.Layer):\n    def __init__(self, **kwargs):\n        super(Mish, self).__init__(**kwargs)\n\n    def call(self, inputs):\n        return inputs * tf.math.tanh(tf.math.softplus(inputs))\n","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:20:42.736701Z","iopub.execute_input":"2023-03-23T14:20:42.737383Z","iopub.status.idle":"2023-03-23T14:20:42.745879Z","shell.execute_reply.started":"2023-03-23T14:20:42.737346Z","shell.execute_reply":"2023-03-23T14:20:42.744861Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tensorflow.keras.layers import Layer\n\nclass gated_swish(Layer):\n    \n    def __init__(self):\n        super(gated_swish, self).__init__()\n\n    def call(self, inputs):\n\n        \"\"\"\n        Gated Swish activation function.\n        \"\"\"\n        gate = tf.math.sigmoid(inputs)\n        activation = tf.nn.swish(inputs)\n        \n        return gate * activation","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:20:42.747940Z","iopub.execute_input":"2023-03-23T14:20:42.749025Z","iopub.status.idle":"2023-03-23T14:20:42.762841Z","shell.execute_reply.started":"2023-03-23T14:20:42.748988Z","shell.execute_reply":"2023-03-23T14:20:42.761754Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class SeLU(tf.keras.layers.Layer):\n    def __init__(self, alpha=1.6732632423543772848170429916717, scale=1.0507009873554804934193349852946, **kwargs):\n        super().__init__(**kwargs)\n        self.alpha = alpha\n        self.scale = scale\n\n    def call(self, inputs):\n        return self.scale * tf.where(inputs > 0.0, inputs, self.alpha * tf.exp(inputs) - self.alpha)\n\n    def get_config(self):\n        config = super().get_config()\n        config.update({'alpha': self.alpha, 'scale': self.scale})\n        return config\n","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:20:42.764304Z","iopub.execute_input":"2023-03-23T14:20:42.765074Z","iopub.status.idle":"2023-03-23T14:20:42.778535Z","shell.execute_reply.started":"2023-03-23T14:20:42.764925Z","shell.execute_reply":"2023-03-23T14:20:42.777560Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import tensorflow as tf\n\nclass LearnableSwish(tf.keras.layers.Layer):\n    def __init__(self, **kwargs):\n        super(LearnableSwish, self).__init__(**kwargs)\n\n    def build(self, input_shape):\n        self.beta = self.add_weight(shape=(1, ), initializer=\"ones\", trainable=True)\n        super(LearnableSwish, self).build(input_shape)\n\n    def call(self, inputs):\n        return tf.nn.swish(inputs * self.beta)","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:20:42.780022Z","iopub.execute_input":"2023-03-23T14:20:42.781959Z","iopub.status.idle":"2023-03-23T14:20:42.796713Z","shell.execute_reply.started":"2023-03-23T14:20:42.781921Z","shell.execute_reply":"2023-03-23T14:20:42.795743Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class SRS(tf.keras.layers.Layer):\n    def __init__(self, alpha=1.0, **kwargs):\n        super(SRS, self).__init__(**kwargs)\n        self.alpha = alpha\n\n    def call(self, inputs):\n        return tf.maximum(inputs, self.alpha * (tf.sigmoid(inputs) - 0.5))\n","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:20:42.798215Z","iopub.execute_input":"2023-03-23T14:20:42.798833Z","iopub.status.idle":"2023-03-23T14:20:42.811278Z","shell.execute_reply.started":"2023-03-23T14:20:42.798796Z","shell.execute_reply":"2023-03-23T14:20:42.810325Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class TanELU(tf.keras.layers.Layer):\n    def __init__(self, alpha=1.0, **kwargs):\n        super(TanELU, self).__init__(**kwargs)\n        self.alpha = alpha\n\n    def call(self, inputs):\n        pos = tf.nn.relu(inputs)\n        neg = self.alpha * (tf.exp(inputs) - 1)\n        return tf.where(inputs > 0, tf.tanh(pos), tf.tanh(neg))","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:20:42.812739Z","iopub.execute_input":"2023-03-23T14:20:42.813373Z","iopub.status.idle":"2023-03-23T14:20:42.826037Z","shell.execute_reply.started":"2023-03-23T14:20:42.813336Z","shell.execute_reply":"2023-03-23T14:20:42.825082Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# !mkdir /kaggle/working/logs","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:20:42.827547Z","iopub.execute_input":"2023-03-23T14:20:42.828180Z","iopub.status.idle":"2023-03-23T14:20:42.835298Z","shell.execute_reply.started":"2023-03-23T14:20:42.828143Z","shell.execute_reply":"2023-03-23T14:20:42.834331Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_inferences={}","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:20:42.836802Z","iopub.execute_input":"2023-03-23T14:20:42.837420Z","iopub.status.idle":"2023-03-23T14:20:42.844343Z","shell.execute_reply.started":"2023-03-23T14:20:42.837384Z","shell.execute_reply":"2023-03-23T14:20:42.843337Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cb = TimingCallback()\n\nUNet_1 = UNet((96, 96, 3), activation_= MexicanReLU())\nmodel1 = UNet_1.buildModel()\nUNet_1.CompileandSummarize(model1)\nresults1 = model1.fit(x = X_train, y = Y_train, batch_size = 8, epochs=150, callbacks = [cb, tf.keras.callbacks.EarlyStopping(monitor='val_loss', patience=10)],  validation_data = (X_test, y_test))\n\ntraining_inferences['MexicanReLU'] = sum(cb.logs)\n","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:30:53.486608Z","iopub.execute_input":"2023-03-23T14:30:53.486999Z","iopub.status.idle":"2023-03-23T14:33:13.156104Z","shell.execute_reply.started":"2023-03-23T14:30:53.486968Z","shell.execute_reply":"2023-03-23T14:33:13.154969Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results1.history['val_loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:38:16.352532Z","iopub.execute_input":"2023-03-23T14:38:16.353714Z","iopub.status.idle":"2023-03-23T14:38:20.764607Z","shell.execute_reply.started":"2023-03-23T14:38:16.353663Z","shell.execute_reply":"2023-03-23T14:38:20.763518Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results1.history['val_iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:38:20.766624Z","iopub.execute_input":"2023-03-23T14:38:20.767002Z","iopub.status.idle":"2023-03-23T14:38:20.990340Z","shell.execute_reply.started":"2023-03-23T14:38:20.766964Z","shell.execute_reply":"2023-03-23T14:38:20.989414Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results1.history['loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:38:20.991841Z","iopub.execute_input":"2023-03-23T14:38:20.992444Z","iopub.status.idle":"2023-03-23T14:38:21.219734Z","shell.execute_reply.started":"2023-03-23T14:38:20.992404Z","shell.execute_reply":"2023-03-23T14:38:21.218803Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results1.history['iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:38:21.222116Z","iopub.execute_input":"2023-03-23T14:38:21.222497Z","iopub.status.idle":"2023-03-23T14:38:21.433040Z","shell.execute_reply.started":"2023-03-23T14:38:21.222460Z","shell.execute_reply":"2023-03-23T14:38:21.432116Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_inferences","metadata":{"execution":{"iopub.status.busy":"2023-03-23T14:38:21.434584Z","iopub.execute_input":"2023-03-23T14:38:21.435188Z","iopub.status.idle":"2023-03-23T14:38:21.442043Z","shell.execute_reply.started":"2023-03-23T14:38:21.435149Z","shell.execute_reply":"2023-03-23T14:38:21.440967Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cb = TimingCallback()\n\nUNet_2 = UNet((96, 96, 3), activation_= Swish())\nmodel2 = UNet_2.buildModel()\nUNet_2.CompileandSummarize(model2)\nresults2 = model2.fit(x = X_train, y = Y_train, batch_size = 8, epochs=150, callbacks = [cb, tf.keras.callbacks.EarlyStopping(monitor='val_loss', patience=10)],  validation_data = (X_test, y_test))\n\ntraining_inferences['Swish'] = sum(cb.logs)","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:07:49.709180Z","iopub.execute_input":"2023-03-22T07:07:49.709785Z","iopub.status.idle":"2023-03-22T07:08:48.333516Z","shell.execute_reply.started":"2023-03-22T07:07:49.709749Z","shell.execute_reply":"2023-03-22T07:08:48.332573Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results2.history['val_loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:08:48.336599Z","iopub.execute_input":"2023-03-22T07:08:48.336885Z","iopub.status.idle":"2023-03-22T07:08:48.537338Z","shell.execute_reply.started":"2023-03-22T07:08:48.336859Z","shell.execute_reply":"2023-03-22T07:08:48.536443Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results2.history['val_iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:08:48.541570Z","iopub.execute_input":"2023-03-22T07:08:48.541844Z","iopub.status.idle":"2023-03-22T07:08:48.747938Z","shell.execute_reply.started":"2023-03-22T07:08:48.541818Z","shell.execute_reply":"2023-03-22T07:08:48.747061Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results2.history['loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:08:48.749169Z","iopub.execute_input":"2023-03-22T07:08:48.750098Z","iopub.status.idle":"2023-03-22T07:08:48.953462Z","shell.execute_reply.started":"2023-03-22T07:08:48.750059Z","shell.execute_reply":"2023-03-22T07:08:48.952550Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results2.history['iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:08:48.954777Z","iopub.execute_input":"2023-03-22T07:08:48.955682Z","iopub.status.idle":"2023-03-22T07:08:49.155981Z","shell.execute_reply.started":"2023-03-22T07:08:48.955643Z","shell.execute_reply":"2023-03-22T07:08:49.155048Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cb = TimingCallback()\n\nUNet_3 = UNet((96, 96, 3), activation_= TrainableLeakyReLU())\nmodel3 = UNet_3.buildModel()\nUNet_3.CompileandSummarize(model3)\nresults3 = model3.fit(x = X_train, y = Y_train, batch_size = 8, epochs=150, callbacks = [cb, tf.keras.callbacks.EarlyStopping(monitor='val_loss', patience=10)],  validation_data = (X_test, y_test))\n\ntraining_inferences['TrainableLeakyReLU'] = sum(cb.logs)","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:08:49.157366Z","iopub.execute_input":"2023-03-22T07:08:49.158509Z","iopub.status.idle":"2023-03-22T07:09:34.044992Z","shell.execute_reply.started":"2023-03-22T07:08:49.158470Z","shell.execute_reply":"2023-03-22T07:09:34.043983Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results3.history['val_loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:09:34.046694Z","iopub.execute_input":"2023-03-22T07:09:34.047080Z","iopub.status.idle":"2023-03-22T07:09:34.288442Z","shell.execute_reply.started":"2023-03-22T07:09:34.047034Z","shell.execute_reply":"2023-03-22T07:09:34.287511Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results3.history['val_iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:09:34.291195Z","iopub.execute_input":"2023-03-22T07:09:34.291537Z","iopub.status.idle":"2023-03-22T07:09:34.516004Z","shell.execute_reply.started":"2023-03-22T07:09:34.291509Z","shell.execute_reply":"2023-03-22T07:09:34.515105Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results3.history['loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:09:34.517243Z","iopub.execute_input":"2023-03-22T07:09:34.517595Z","iopub.status.idle":"2023-03-22T07:09:34.732354Z","shell.execute_reply.started":"2023-03-22T07:09:34.517559Z","shell.execute_reply":"2023-03-22T07:09:34.731469Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results3.history['iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:09:34.733813Z","iopub.execute_input":"2023-03-22T07:09:34.734180Z","iopub.status.idle":"2023-03-22T07:09:34.951346Z","shell.execute_reply.started":"2023-03-22T07:09:34.734128Z","shell.execute_reply":"2023-03-22T07:09:34.950413Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_inferences","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:09:34.952947Z","iopub.execute_input":"2023-03-22T07:09:34.953316Z","iopub.status.idle":"2023-03-22T07:09:34.963079Z","shell.execute_reply.started":"2023-03-22T07:09:34.953280Z","shell.execute_reply":"2023-03-22T07:09:34.962137Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cb = TimingCallback()\n\nUNet_4 = UNet((96, 96, 3), activation_= ISRU())\nmodel4 = UNet_4.buildModel()\nUNet_4.CompileandSummarize(model4)\nresults4 = model4.fit(x = X_train, y = Y_train, batch_size = 8, epochs=150, callbacks = [cb, tf.keras.callbacks.EarlyStopping(monitor='val_loss', patience=10)], validation_data = (X_test, y_test))\n\ntraining_inferences['ISRU'] = sum(cb.logs)","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:09:34.966498Z","iopub.execute_input":"2023-03-22T07:09:34.966771Z","iopub.status.idle":"2023-03-22T07:10:48.391338Z","shell.execute_reply.started":"2023-03-22T07:09:34.966740Z","shell.execute_reply":"2023-03-22T07:10:48.390407Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results4.history['val_loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:10:48.393657Z","iopub.execute_input":"2023-03-22T07:10:48.394008Z","iopub.status.idle":"2023-03-22T07:10:48.595091Z","shell.execute_reply.started":"2023-03-22T07:10:48.393973Z","shell.execute_reply":"2023-03-22T07:10:48.594153Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results3.history['val_iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:10:48.596715Z","iopub.execute_input":"2023-03-22T07:10:48.597337Z","iopub.status.idle":"2023-03-22T07:10:48.812509Z","shell.execute_reply.started":"2023-03-22T07:10:48.597296Z","shell.execute_reply":"2023-03-22T07:10:48.811569Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results3.history['loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:10:48.814037Z","iopub.execute_input":"2023-03-22T07:10:48.814649Z","iopub.status.idle":"2023-03-22T07:10:49.025050Z","shell.execute_reply.started":"2023-03-22T07:10:48.814613Z","shell.execute_reply":"2023-03-22T07:10:49.024087Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results3.history['iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:10:49.026429Z","iopub.execute_input":"2023-03-22T07:10:49.027632Z","iopub.status.idle":"2023-03-22T07:10:49.240701Z","shell.execute_reply.started":"2023-03-22T07:10:49.027593Z","shell.execute_reply":"2023-03-22T07:10:49.239726Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cb = TimingCallback()\n\nUNet_5 = UNet((96, 96, 3), activation_= Mish())\nmodel5 = UNet_5.buildModel()\nUNet_5.CompileandSummarize(model5)\nresults5 = model5.fit(x = X_train, y = Y_train, batch_size = 8, epochs=150, callbacks = [cb, tf.keras.callbacks.EarlyStopping(monitor='val_loss', patience=10)], validation_data = (X_test, y_test))\n\ntraining_inferences['Mish'] = sum(cb.logs)\n","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:10:49.242231Z","iopub.execute_input":"2023-03-22T07:10:49.242589Z","iopub.status.idle":"2023-03-22T07:11:50.931480Z","shell.execute_reply.started":"2023-03-22T07:10:49.242554Z","shell.execute_reply":"2023-03-22T07:11:50.930372Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results5.history['val_loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:11:50.933095Z","iopub.execute_input":"2023-03-22T07:11:50.933491Z","iopub.status.idle":"2023-03-22T07:12:13.501982Z","shell.execute_reply.started":"2023-03-22T07:11:50.933454Z","shell.execute_reply":"2023-03-22T07:12:13.501103Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results5.history['val_iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:12:13.504936Z","iopub.execute_input":"2023-03-22T07:12:13.505238Z","iopub.status.idle":"2023-03-22T07:12:13.708021Z","shell.execute_reply.started":"2023-03-22T07:12:13.505211Z","shell.execute_reply":"2023-03-22T07:12:13.707087Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results5.history['loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:12:13.709544Z","iopub.execute_input":"2023-03-22T07:12:13.710165Z","iopub.status.idle":"2023-03-22T07:12:13.910105Z","shell.execute_reply.started":"2023-03-22T07:12:13.710111Z","shell.execute_reply":"2023-03-22T07:12:13.909192Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results5.history['iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:12:13.916024Z","iopub.execute_input":"2023-03-22T07:12:13.916572Z","iopub.status.idle":"2023-03-22T07:12:14.123009Z","shell.execute_reply.started":"2023-03-22T07:12:13.916544Z","shell.execute_reply":"2023-03-22T07:12:14.122093Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cb = TimingCallback()\n\nUNet_6 = UNet((96, 96, 3), activation_= gated_swish())\nmodel6 = UNet_6.buildModel()\nUNet_6.CompileandSummarize(model6)\nresults6 = model6.fit(x = X_train, y = Y_train, batch_size = 8, epochs=150, callbacks = [cb, tf.keras.callbacks.EarlyStopping(monitor='val_loss', patience=10)], validation_data = (X_test, y_test))\n\ntraining_inferences['gated_swish'] = sum(cb.logs)\n","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:12:14.125977Z","iopub.execute_input":"2023-03-22T07:12:14.126289Z","iopub.status.idle":"2023-03-22T07:13:03.328466Z","shell.execute_reply.started":"2023-03-22T07:12:14.126262Z","shell.execute_reply":"2023-03-22T07:13:03.327512Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results6.history['val_loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:13:03.329980Z","iopub.execute_input":"2023-03-22T07:13:03.330360Z","iopub.status.idle":"2023-03-22T07:13:03.550755Z","shell.execute_reply.started":"2023-03-22T07:13:03.330324Z","shell.execute_reply":"2023-03-22T07:13:03.549793Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results6.history['val_iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:13:03.552332Z","iopub.execute_input":"2023-03-22T07:13:03.552935Z","iopub.status.idle":"2023-03-22T07:13:03.764069Z","shell.execute_reply.started":"2023-03-22T07:13:03.552896Z","shell.execute_reply":"2023-03-22T07:13:03.763080Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results6.history['iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:13:03.765464Z","iopub.execute_input":"2023-03-22T07:13:03.765857Z","iopub.status.idle":"2023-03-22T07:13:03.982968Z","shell.execute_reply.started":"2023-03-22T07:13:03.765818Z","shell.execute_reply":"2023-03-22T07:13:03.982039Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results6.history['loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:13:03.984356Z","iopub.execute_input":"2023-03-22T07:13:03.985341Z","iopub.status.idle":"2023-03-22T07:13:04.195803Z","shell.execute_reply.started":"2023-03-22T07:13:03.985304Z","shell.execute_reply":"2023-03-22T07:13:04.194923Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cb = TimingCallback()\n\nUNet__ = UNet((96, 96, 3), activation_= \"relu\")\nmodel_ = UNet__.buildModel()\nUNet__.CompileandSummarize(model_)\nresults_ = model5.fit(x = X_train, y = Y_train, batch_size = 8, epochs=150, callbacks = [cb, tf.keras.callbacks.EarlyStopping(monitor='val_loss', patience=10)], validation_data = (X_test, y_test))\n\ntraining_inferences['relu'] = sum(cb.logs)\n","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:21:09.436291Z","iopub.execute_input":"2023-03-22T07:21:09.436663Z","iopub.status.idle":"2023-03-22T07:21:34.532014Z","shell.execute_reply.started":"2023-03-22T07:21:09.436634Z","shell.execute_reply":"2023-03-22T07:21:34.531060Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results_.history['val_loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:21:34.533871Z","iopub.execute_input":"2023-03-22T07:21:34.534163Z","iopub.status.idle":"2023-03-22T07:21:50.991470Z","shell.execute_reply.started":"2023-03-22T07:21:34.534120Z","shell.execute_reply":"2023-03-22T07:21:50.990514Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results_.history['val_iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:21:50.993003Z","iopub.execute_input":"2023-03-22T07:21:50.993622Z","iopub.status.idle":"2023-03-22T07:21:51.196783Z","shell.execute_reply.started":"2023-03-22T07:21:50.993584Z","shell.execute_reply":"2023-03-22T07:21:51.195829Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results_.history['loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:21:51.198970Z","iopub.execute_input":"2023-03-22T07:21:51.199378Z","iopub.status.idle":"2023-03-22T07:21:51.396697Z","shell.execute_reply.started":"2023-03-22T07:21:51.199340Z","shell.execute_reply":"2023-03-22T07:21:51.395779Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results_.history['iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:21:51.398023Z","iopub.execute_input":"2023-03-22T07:21:51.398402Z","iopub.status.idle":"2023-03-22T07:21:51.592915Z","shell.execute_reply.started":"2023-03-22T07:21:51.398368Z","shell.execute_reply":"2023-03-22T07:21:51.591994Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cb = TimingCallback()\n\nUNet_ls = UNet((96, 96, 3), activation_= LearnableSwish())\nmodells = UNet_ls.buildModel()\nUNet_ls.CompileandSummarize(modells)\nresultsls = modells.fit(x = X_train, y = Y_train, batch_size = 8, epochs=150, callbacks = [cb, tf.keras.callbacks.EarlyStopping(monitor='val_loss', patience=10)], validation_data = (X_test, y_test))\n\ntraining_inferences['LearnableSwish'] = sum(cb.logs)","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:16:48.995338Z","iopub.execute_input":"2023-03-22T07:16:48.996040Z","iopub.status.idle":"2023-03-22T07:17:57.025040Z","shell.execute_reply.started":"2023-03-22T07:16:48.996002Z","shell.execute_reply":"2023-03-22T07:17:57.024027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(resultsls.history['val_loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:17:57.026971Z","iopub.execute_input":"2023-03-22T07:17:57.027430Z","iopub.status.idle":"2023-03-22T07:18:13.645825Z","shell.execute_reply.started":"2023-03-22T07:17:57.027394Z","shell.execute_reply":"2023-03-22T07:18:13.644868Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(resultsls.history['val_iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:18:13.647368Z","iopub.execute_input":"2023-03-22T07:18:13.647969Z","iopub.status.idle":"2023-03-22T07:18:13.858156Z","shell.execute_reply.started":"2023-03-22T07:18:13.647929Z","shell.execute_reply":"2023-03-22T07:18:13.857086Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(resultsls.history['loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:18:13.860632Z","iopub.execute_input":"2023-03-22T07:18:13.861188Z","iopub.status.idle":"2023-03-22T07:18:14.075318Z","shell.execute_reply.started":"2023-03-22T07:18:13.861132Z","shell.execute_reply":"2023-03-22T07:18:14.074373Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(resultsls.history['iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:18:14.076632Z","iopub.execute_input":"2023-03-22T07:18:14.077414Z","iopub.status.idle":"2023-03-22T07:18:14.277139Z","shell.execute_reply.started":"2023-03-22T07:18:14.077376Z","shell.execute_reply":"2023-03-22T07:18:14.276078Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cb = TimingCallback()\n\nUNet_srs = UNet((96, 96, 3), activation_= SRS())\nmodelsrs = UNet_srs.buildModel()\nUNet_srs.CompileandSummarize(modelsrs)\nresultssrs = modells.fit(x = X_train, y = Y_train, batch_size = 8, epochs=150, callbacks = [cb, tf.keras.callbacks.EarlyStopping(monitor='val_loss', patience=10)], validation_data = (X_test, y_test))\n\ntraining_inferences['SRS'] = sum(cb.logs)","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:18:14.278635Z","iopub.execute_input":"2023-03-22T07:18:14.278979Z","iopub.status.idle":"2023-03-22T07:18:50.773081Z","shell.execute_reply.started":"2023-03-22T07:18:14.278942Z","shell.execute_reply":"2023-03-22T07:18:50.772109Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(resultssrs.history['val_loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:18:50.775178Z","iopub.execute_input":"2023-03-22T07:18:50.775640Z","iopub.status.idle":"2023-03-22T07:18:55.852346Z","shell.execute_reply.started":"2023-03-22T07:18:50.775602Z","shell.execute_reply":"2023-03-22T07:18:55.851280Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(resultssrs.history['val_iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:18:55.853730Z","iopub.execute_input":"2023-03-22T07:18:55.854204Z","iopub.status.idle":"2023-03-22T07:18:56.056958Z","shell.execute_reply.started":"2023-03-22T07:18:55.854166Z","shell.execute_reply":"2023-03-22T07:18:56.056039Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(resultssrs.history['loss'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:18:56.058545Z","iopub.execute_input":"2023-03-22T07:18:56.059204Z","iopub.status.idle":"2023-03-22T07:18:56.270974Z","shell.execute_reply.started":"2023-03-22T07:18:56.059164Z","shell.execute_reply":"2023-03-22T07:18:56.270055Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(resultssrs.history['iou'])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:18:56.274275Z","iopub.execute_input":"2023-03-22T07:18:56.274552Z","iopub.status.idle":"2023-03-22T07:18:56.473501Z","shell.execute_reply.started":"2023-03-22T07:18:56.274527Z","shell.execute_reply":"2023-03-22T07:18:56.472573Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_inferences","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:22:22.297105Z","iopub.execute_input":"2023-03-22T07:22:22.297515Z","iopub.status.idle":"2023-03-22T07:22:22.304993Z","shell.execute_reply.started":"2023-03-22T07:22:22.297483Z","shell.execute_reply":"2023-03-22T07:22:22.303978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = []\ny = []\n\nfor i in training_inferences:\n    x.append(i)\n    y.append(training_inferences[i])","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:23:31.544882Z","iopub.execute_input":"2023-03-22T07:23:31.545284Z","iopub.status.idle":"2023-03-22T07:23:31.551057Z","shell.execute_reply.started":"2023-03-22T07:23:31.545250Z","shell.execute_reply":"2023-03-22T07:23:31.549897Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#'Comparision of training times in different activation functions\nfig, ax = plt.subplots()\nplt.bar(range(len(y)), y, tick_label=x)\nplt.xticks(rotation='vertical')\nfig.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T07:36:39.776606Z","iopub.execute_input":"2023-03-22T07:36:39.776976Z","iopub.status.idle":"2023-03-22T07:36:40.014984Z","shell.execute_reply.started":"2023-03-22T07:36:39.776945Z","shell.execute_reply":"2023-03-22T07:36:40.014052Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}