Exemple #1
0
def get_model(input_channels,
              input_time_length,
              dilations=None,
              kernel_sizes=None,
              padding=False):
    """
    initializes a new Deep4Net and changes the kernel sizes and dilations of the network based on the input parameters
    :param input_channels: 1 axis input shape
    :param input_time_length: 0 axis input shape
    :param dilations: dilations of the max-pool layers of the network
    :param kernel_sizes: kernel sizes of the max-pool layers of the network
    :param padding: if padding is to be added

    :return: a Model object, the changed Deep4Net based on the kernel sizes and dilation parameters and the name
    of the model based on the kernel sizes and dilatiosn
    """
    if kernel_sizes is None:
        kernel_sizes = [3, 3, 3, 3]
    print('SBP False!!!')
    model = Model(input_channels=input_channels,
                  n_classes=1,
                  input_time_length=input_time_length,
                  final_conv_length=2,
                  stride_before_pool=False)
    model.make_regressor()
    if cuda:
        model.model = model.model.cuda()

    model_name = get_model_name_from_kernel_and_dilation(
        kernel_sizes, dilations)

    changed_model = change_network_kernel_and_dilation(model.model,
                                                       kernel_sizes,
                                                       dilations,
                                                       remove_maxpool=False)
    # print(changed_model)

    return model, changed_model, model_name