コード例 #1
0
def objective_func(batch_size,
                   lookback,
                   lr,
                   lstm_units,
                   lstm_act='relu',
                   cnn_act='relu',
                   filters=64):

    n_epochs = 5000

    data_config, nn_config, args, intervals, verbosity = make_model(
        int(batch_size), int(lookback), n_epochs, lr, lstm_act, cnn_act,
        lstm_units, filters)

    model = Model(data_config=data_config,
                  nn_config=nn_config,
                  args=args,
                  intervals=intervals,
                  verbosity=verbosity)

    model.build_nn()
    model.train_nn()

    mse = np.min(model.losses['val_losses']['mse'])

    reset_graph()

    return mse
コード例 #2
0
def objective_fn(**kwargs):
    data_config, nn_config, total_intervals = make_model(**kwargs)

    df = pd.read_csv('data/nk_data.csv')

    model = Model(
        data_config=data_config,
        nn_config=nn_config,
        data=df,
        # intervals=total_intervals
    )

    model.build_nn()

    idx = np.arange(720)
    tr_idx, test_idx = train_test_split(idx, test_size=0.5, random_state=313)

    history = model.train_nn(indices=list(tr_idx))
    return np.min(history['val_loss'])