Ejemplo n.º 1
0
def main():
    # load midi
    dirpath = '../'
    pieces = loadPieces(dirpath)

    # divide train valid
    valid_pieces = pieces[:num_valid]
    train_pieces = pieces[num_valid:]
    valid_gen = BatchGenerator(pieces[0], valid_batch_size, 1)
    train_gen = MixedGenarator(pieces, batch_size, num_unrolling)

    # create model ans start training
    model = LSTM_model(layer_size, batch_size, num_unrolling)
    model.train(train_gen, valid_gen, train_step=10000, summary_frequency=100)
Ejemplo n.º 2
0
df = pd.io.gbq.read_gbq(query, project_id=project_id)

dataset = dataset(df,
                  table='snp',
                  min_date=dt.datetime(2010,
                                       1,
                                       1,
                                       0,
                                       0,
                                       0,
                                       tzinfo=dt.timezone.utc),
                  max_date=dt.datetime(2020,
                                       6,
                                       1,
                                       0,
                                       0,
                                       0,
                                       tzinfo=dt.timezone.utc))
dataset.prepare_dataset()
model = LSTM_model(1, 'snp')
train_data_generator = datagen(df=dataset.traindata,
                               gen_length=model.model_params['SEQ_LEN'],
                               batch_size=model.model_params['batch_size'],
                               shuffle=False)
test_data_generator = datagen(df=dataset.testdata,
                              gen_length=model.model_params['SEQ_LEN'],
                              batch_size=model.model_params['batch_size'],
                              shuffle=False)
model.train(train_gen=train_data_generator, validation_gen=test_data_generator)