[{'role': 'system', 'content': "You are an expert in machine learning and your task is to classify code snippets into one of the following categories: ['helper_functions', 'load_data', 'data_exploration', 'data_preprocessing', 'evaluation', 'modelling', 'prediction', 'result_visualization', 'save_results', 'comment_only']."}, {'role': 'user', 'content': 'Identify the single most appropriate category to which the provided code belongs. Provide your response as a single category label without any additional information, commentary, or personal opinions.\\nPython Code:########################################################################################################################\n# ======================================================================================================================\n# u_model\n# ======================================================================================================================\n########################################################################################################################\n# needed for train\n\n# standard-module imports\nimport numpy as np\nfrom keras.layers import Input, concatenate, Conv2D, UpSampling2D, Dense\nfrom keras.layers import Dropout, Flatten\nfrom keras.models import Model\nfrom keras.optimizers import Adam\nfrom keras import backend as K\n\n# # separate-module imports\n# from metric import dice_coef, dice_coef_loss\n# from u_model_blocks import pooling_block, connection_block, information_block\n# from configuration import ALLOWED_PARS, PARS\n\n\nIMG_ROWS, IMG_COLS = 80, 112\nK.set_image_data_format(\'channels_last\')  # (number of images, rows per image, cols per image, channels)\n\n\n# ======================================================================================================================\n# U-net with Inception blocks, Normalised 2D Convolutions instead of Maxpooling\n# ======================================================================================================================\n\ndef get_unet_customised(optimizer, pars=PARS, allowed_pars=ALLOWED_PARS):\n    """\n    Creating and compiling the U-net\n\n    This version is fully customisable by choosing pars argument\n\n    :param optimizer: specifies the optimiser for the u-net, e.g. Adam, RMSProp, etc.\n    :param pars: optional, dictionary of parameters passed to customise the U-net\n    :param allowed_pars: optional, dictionary of parameters allowed to be passed to customise the U-net\n    :return: compiled u-net, Keras.Model object\n    """\n\n    # string, activation function\n    activation = pars.get(\'activation\')\n\n    # input\n    inputs = Input((IMG_ROWS, IMG_COLS, 1), name=\'main_input\')\n    print(\'inputs:\', inputs._keras_shape)\n\n    #\n    # down the U-net\n    #\n\n    conv1 = information_block(inputs, 32, padding=\'same\', activation=activation, pars=pars, allowed_pars=allowed_pars)\n    print(\'conv1\', conv1._keras_shape)\n    pool1 = pooling_block(inputs=conv1, filters=32, activation=activation, pars=pars, allowed_pars=allowed_pars)\n    print(\'pool1\', pool1._keras_shape)\n    pool1 = Dropout(0.5)(pool1)\n    print(\'pool1\', pool1._keras_shape)\n\n    conv2 = information_block(pool1, 64, padding=\'same\', activation=activation, pars=pars, allowed_pars=allowed_pars)\n    print(\'conv2\', conv2._keras_shape)\n    pool2 = pooling_block(inputs=conv2, filters=64, activation=activation, pars=pars, allowed_pars=allowed_pars)\n    print(\'pool2\', pool2._keras_shape)\n    pool2 = Dropout(0.5)(pool2)\n    print(\'pool2\', pool2._keras_shape)\n\n    conv3 = information_block(pool2, 128, padding=\'same\', activation=activation, pars=pars, allowed_pars=allowed_pars)\n    print(\'conv3\', conv3._keras_shape)\n    pool3 = pooling_block(inputs=conv3, filters=128, activation=activation, pars=pars, allowed_pars=allowed_pars)\n    print(\'pool3\', pool3._keras_shape)\n    pool3 = Dropout(0.5)(pool3)\n    print(\'pool3\', pool3._keras_shape)\n\n    conv4 = information_block(pool3, 256, padding=\'same\', activation=activation, pars=pars, allowed_pars=allowed_pars)\n    print(\'conv4\', conv4._keras_shape)\n    pool4 = pooling_block(inputs=conv4, filters=256, activation=activation, pars=pars, allowed_pars=allowed_pars)\n    print(\'pool4\', pool4._keras_shape)\n    pool4 = Dropout(0.5)(pool4)\n    print(\'pool4\', pool4._keras_shape)\n\n    #\n    # bottom level of the U-net\n    #\n    conv5 = information_block(pool4, 512, padding=\'same\', activation=activation, pars=pars, allowed_pars=allowed_pars)\n    print(\'conv5\', conv5._keras_shape)\n    conv5 = Dropout(0.5)(conv5)\n    print(\'conv5\', conv5._keras_shape)\n\n    #\n    # auxiliary output for predicting probability of nerve presence\n    #\n    if pars[\'outputs\'] == 2:\n        pre = Conv2D(1, kernel_size=(1, 1), kernel_initializer=\'he_normal\', activation=\'sigmoid\')(conv5)\n        pre = Flatten()(pre)\n        aux_out = Dense(1, activation=\'sigmoid\', name=\'aux_output\')(pre)\n\n    #\n    # up the U-net\n    #\n\n    after_conv4 = connection_block(conv4, 256, padding=\'same\', activation=activation,\n                                   pars=pars, allowed_pars=allowed_pars)\n    print(\'after_conv4\', after_conv4._keras_shape)\n    up6 = concatenate([UpSampling2D(size=(2, 2))(conv5), after_conv4], axis=3)\n    conv6 = information_block(up6, 256, padding=\'same\', activation=activation, pars=pars, allowed_pars=allowed_pars)\n    print(\'conv6\', conv6._keras_shape)\n    conv6 = Dropout(0.5)(conv6)\n    print(\'conv6\', conv6._keras_shape)\n\n    after_conv3 = connection_block(conv3, 128, padding=\'same\', activation=activation,\n                                   pars=pars, allowed_pars=allowed_pars)\n    print(\'after_conv3\', after_conv3._keras_shape)\n    up7 = concatenate([UpSampling2D(size=(2, 2))(conv6), after_conv3], axis=3)\n    conv7 = information_block(up7, 128, padding=\'same\', activation=activation, pars=pars, allowed_pars=allowed_pars)\n    print(\'conv7\', conv7._keras_shape)\n    conv7 = Dropout(0.5)(conv7)\n    print(\'conv7\', conv7._keras_shape)\n\n    after_conv2 = connection_block(conv2, 64, padding=\'same\', activation=activation, pars=pars,\n                                   allowed_pars=allowed_pars)\n    print(\'after_conv2\', after_conv2._keras_shape)\n    up8 = concatenate([UpSampling2D(size=(2, 2))(conv7), after_conv2], axis=3)\n    conv8 = information_block(up8, 64, padding=\'same\', activation=activation, pars=pars, allowed_pars=allowed_pars)\n    print(\'conv8\', conv8._keras_shape)\n    conv8 = Dropout(0.5)(conv8)\n    print(\'conv8\', conv8._keras_shape)\n\n    after_conv1 = connection_block(conv1, 32, padding=\'same\', activation=activation,\n                                   pars=pars, allowed_pars=allowed_pars)\n    print(\'after_conv1\', after_conv1._keras_shape)\n    up9 = concatenate([UpSampling2D(size=(2, 2))(conv8), after_conv1], axis=3)\n    conv9 = information_block(up9, 32, padding=\'same\', activation=activation, pars=pars, allowed_pars=allowed_pars)\n    print(\'conv9\', conv9._keras_shape)\n    conv9 = Dropout(0.5)(conv9)\n    print(\'conv9\', conv9._keras_shape)\n\n    # main output\n    conv10 = Conv2D(1, kernel_size=(1, 1), kernel_initializer=\'he_normal\', activation=\'sigmoid\', name=\'main_output\')(\n        conv9)\n    print(\'conv10\', conv10._keras_shape)\n\n    # creating a model\n    # compiling the model\n    if pars[\'outputs\'] == 1:\n        model = Model(inputs=inputs, outputs=conv10)\n        model.compile(optimizer=optimizer,\n                      loss={\'main_output\': dice_coef_loss},\n                      metrics={\'main_output\': dice_coef})\n    else:\n        model = Model(inputs=inputs, outputs=[conv10, aux_out])\n        model.compile(optimizer=optimizer,\n                      loss={\'main_output\': dice_coef_loss, \'aux_output\': \'binary_crossentropy\'},\n                      metrics={\'main_output\': dice_coef, \'aux_output\': \'acc\'},\n                      loss_weights={\'main_output\': 1., \'aux_output\': 0.5})\n\n    return model\n\n\n# ----------------------------------------------------------------------------------------------------------------------\n\n# get_unet() allows to try other versions of the u-net, if more are specified\nget_unet = get_unet_customised\n\nif __name__ == \'__main__\' and (execute_u_model==True or execute_all==True):\n    # test the u-net without training\n\n    img_rows = IMG_ROWS\n    img_cols = IMG_COLS\n\n    # to check that model works without training, any kind of optimiser can be used\n    model = get_unet(Adam(lr=1e-5), pars=PARS)\n\n    x = np.random.random((1, img_rows, img_cols, 1))\n    result = model.predict(x, 1)\n    print(result)\n    print(\'params\', model.count_params())\n    print(\'layer num\', len(model.layers))\''}, {'role': 'assistant', 'content': 'helper_functions'}]