Example #1
0
def getModel(name, nb_res_units, dayInfo_dim):
    if MODELNAME == 'STResNet':
        c_dim = (HEIGHT, WIDTH, nb_channel, len_c)
        p_dim = (HEIGHT, WIDTH, nb_channel, len_p)
        t_dim = (HEIGHT, WIDTH, nb_channel, len_t)

        model = stresnet(c_dim=c_dim,
                         p_dim=p_dim,
                         t_dim=t_dim,
                         residual_units=nb_res_units,
                         dayInfo_dim=dayInfo_dim)
        #model.summary()
        return model
    else:
        return None
def build_model(external_dim):
    c_conf = (len_closeness, nb_flow, map_height,
              map_width) if len_closeness > 0 else None
    p_conf = (len_period, nb_flow, map_height,
              map_width) if len_period > 0 else None
    t_conf = (len_trend, nb_flow, map_height,
              map_width) if len_trend > 0 else None

    model = stresnet(c_conf=c_conf,
                     p_conf=p_conf,
                     t_conf=t_conf,
                     external_dim=external_dim,
                     nb_residual_unit=nb_residual_unit)
    adam = Adam(lr=lr)
    model.compile(loss='mse', optimizer=adam, metrics=[metrics.rmse])
    model.summary()
    # from keras.utils.visualize_util import plot
    from keras.utils.vis_utils import plot_model
    plot_model(model, to_file='model.png', show_shapes=True)
    return model