Ejemplo n.º 1
0
def getModel(cloud_dim, precipitation_dim, wind_dim, humidity_dim, pressure_dim, temperature_dim,
             ocean_dim=None, other_dim=None, target_shape=1, name="resnetLSTM"):
    # input to the model
    input_array = getInput(cloud_dim, precipitation_dim, wind_dim, humidity_dim, pressure_dim, temperature_dim,
                           ocean_dim)
    if other_dim:
        other_in = Input(shape=other_dim, name="OtherParam")
        input_array.append(other_in)

    x = concatenate_together([expandForCNN(i) for i in input_array])
    for _ in range(8):
        x = BatchNormalization()(x)
        x = ResidualBlock(x, filters=8, kernel_size=3, strides=(1, 1), padding='same', shortcut=True)
    x = MaxPooling2D(pool_size=(2, 2))(x)
    x = BatchNormalization()(x)
    x = Conv2D(16, kernel_size=(3, 3), padding='same', activation=relu)(x)
    x = MaxPooling2D(pool_size=(2, 2))(x)
    x = BatchNormalization()(x)
    x = Flatten()(x) if other_dim is None else flattenAll([x, other_in])
    x = BatchNormalization()(x)
    # unify output layer
    x = Dense(256, activation=relu)(x)
    x = BatchNormalization()(x)
    # last stage processing
    x = LSTM(128)(expand_dims(x, -1))

    pred = getOutput(x, target_shape)
    m = Model(inputs=input_array, outputs=pred, name=name)
    return m
Ejemplo n.º 2
0
def getModel(cloud_dim,
             precipitation_dim,
             wind_dim,
             humidity_dim,
             pressure_dim,
             temperature_dim,
             ocean_dim=None,
             other_dim=None,
             target_shape=1,
             name="vcnnLSTM"):
    # input to the model
    input_array = getInput(cloud_dim, precipitation_dim, wind_dim,
                           humidity_dim, pressure_dim, temperature_dim,
                           ocean_dim)
    if other_dim:
        other_in = Input(shape=other_dim, name="OtherParam")
        input_array.append(other_in)

    # CNN
    x = [
        AutoSetDenseOrCNN(i,
                          horizontal=True,
                          dropout=False,
                          activation=relu,
                          padding="valid") for i in input_array
    ]
    x1 = concatenate_together(list(filter(lambda i: len(i.shape) == 4, x)),
                              axis=1)
    x2 = concatenate_together(list(filter(lambda i: len(i.shape) != 4, x)),
                              axis=1)

    x1 = MaxPooling2D(pool_size=(2, 1))(Conv2D(
        16, kernel_size=(2, 1), padding='same', activation=relu)(
            BatchNormalization()(x1))) if x1 is not None else None
    x2 = Dense(x2.shape[1] * 2, activation=relu)(
        BatchNormalization()(x2)) if x2 is not None else None
    if x1 is not None and x2 is not None:
        x = flattenAll([x1, x2])
    else:
        x = Flatten()(x1) if x1 is not None else Flatten()(x2)

    # unify output layer
    x = BatchNormalization()(x)
    x = Dense(256, activation=relu)(x)

    # last stage processing
    x = BatchNormalization()(x)
    x = LSTM(128)(expand_dims(x, -1))
    pred = getOutput(x, target_shape)
    m = Model(inputs=input_array, outputs=pred, name=name)
    return m
Ejemplo n.º 3
0
def getModel(cloud_dim, precipitation_dim, wind_dim, humidity_dim, pressure_dim, temperature_dim,
             ocean_dim=None, other_dim=None, target_shape=1, name="ann"):
    # input to the model
    input_array = getInput(cloud_dim, precipitation_dim, wind_dim, humidity_dim, pressure_dim, temperature_dim,
                           ocean_dim)
    if other_dim:
        other_in = Input(shape=other_dim, name="OtherParam")
        input_array.append(other_in)
    # flatten all data and concatenate together
    x = flattenAll(input_array)
    x = BatchNormalization()(x)
    x = Dense(512, activation=relu)(x)
    x = BatchNormalization()(x)

    # unify output layer
    x = Dense(256, activation=relu)(x)
    x = BatchNormalization()(x)
    # last stage processing
    x = LeakyReLU()(Dense(128)(x))
    x = BatchNormalization()(x)
    pred = getOutput(x, target_shape)
    m = Model(inputs=input_array, outputs=pred, name=name)
    return m
Ejemplo n.º 4
0
def getModel(cloud_dim,
             precipitation_dim,
             wind_dim,
             humidity_dim,
             pressure_dim,
             temperature_dim,
             ocean_dim=None,
             other_dim=None,
             target_shape=1,
             name="resnet"):
    # input to the model
    input_array = getInput(cloud_dim, precipitation_dim, wind_dim,
                           humidity_dim, pressure_dim, temperature_dim,
                           ocean_dim)
    if other_dim:
        other_in = Input(shape=other_dim, name="OtherParam")
        input_array.append(other_in)

    x = concatenate_together([expandForCNN(i) for i in input_array])
    for _ in range(8):
        x = invertedResidualBlock(x,
                                  in_channel=1,
                                  out_channel=8,
                                  kernel_size=3,
                                  expansion_rate=8,
                                  strides=(1, 1))

    x = dsConv2D(x,
                 in_channel=8,
                 out_channel=8,
                 kernel_size=3,
                 strides=1,
                 padding="valid")
    x = dsConv2D(x,
                 in_channel=8,
                 out_channel=16,
                 kernel_size=3,
                 strides=1,
                 padding="valid")
    x = dsConv2D(x,
                 in_channel=16,
                 out_channel=16,
                 kernel_size=3,
                 strides=1,
                 padding="valid")
    x = dsConv2D(x,
                 in_channel=16,
                 out_channel=32,
                 kernel_size=3,
                 strides=1,
                 padding="valid")
    x = dsConv2D(x,
                 in_channel=32,
                 out_channel=32,
                 kernel_size=3,
                 strides=1,
                 padding="valid")
    # x = dsConv2D(x, in_channel=32, out_channel=64, kernel_size=3, strides=1, padding="valid")
    # x = dsConv2D(x, in_channel=64, out_channel=64, kernel_size=3, strides=1, padding="valid")

    x = Flatten()(x)
    # unify output layer
    x = Dense(256, activation=relu)(x)

    # last stage processing
    x = LeakyReLU()(Dense(128)(x))
    pred = getOutput(x, target_shape)
    m = Model(inputs=input_array, outputs=pred, name=name)
    return m