Ejemplo n.º 1
0
def main():
    x,y=PassengerData(params).get_examples(data_dir='../data/international-airline-passengers.csv')
    print(x.shape,y.shape)

    model=Model(params=params,use_model='seq2seq')
    y_pred=model.predict(x.astype(np.float32), model_dir=params['saved_model_dir'])
    print(y_pred)
Ejemplo n.º 2
0
def main(plot=False):
    x, y = PassengerData(params).get_examples(
        data_dir='../data/international-airline-passengers.csv', sample=0.2)
    print(x.shape, y.shape)

    model = Model(params=params, use_model=params['use_model'])
    try:
        y_pred = model.predict(x.astype(np.float32),
                               model_dir=params['saved_model_dir'])
    except:
        y_pred = model.predict((x.astype(np.float32), np.ones_like(y)),
                               model_dir=params['saved_model_dir'])

    print(y_pred)

    if plot:
        for i in range(y_pred.shape[1]):
            plt.subplot(y_pred.shape[1], 1, i + 1)
            plt.plot(y[:, i, 0], label='true')
            plt.plot(y_pred[:, i], label='pred')
            plt.legend()
        plt.show()

        for i in range(36):
            plt.subplot(6, 6, i + 1)
            i = np.random.choice(range(y_pred.shape[0]))
            plt.plot(y[i, :, 0], label='true')
            plt.plot(y_pred[i, :], label='pred')
            plt.legend()
        plt.show()

    return y, y_pred
Ejemplo n.º 3
0
def main():
    data_loader = DataLoader(data_dir=params['data_dir'])
    dataset = data_loader(batch_size=8, training=True)

    model = Model(use_model=params['use_model'],
                  params=params,
                  use_loss='mse',
                  use_optimizer='adam')  # model: seq2seq, tcn, transformer
    model.train(dataset, n_epochs=10,
                mode='eager')  # mode can choose eager or fit
Ejemplo n.º 4
0
def main():
    data_loader = DataLoader()
    train_dataset = data_loader(params,
                                data_dir=params['data_dir'],
                                batch_size=params['batch_size'],
                                training=True,
                                sample=0.8)
    valid_dataset = data_loader(params,
                                data_dir=params['data_dir'],
                                batch_size=params['batch_size'],
                                training=True,
                                sample=0.2)

    # use_model: seq2seq, wavenet, transformer
    model = Model(params=params,
                  use_model=params['use_model'],
                  use_loss='mse',
                  use_optimizer='adam',
                  custom_model_params={})
    # mode: eager or fit
    model.train(train_dataset,
                n_epochs=params['n_epochs'],
                mode='eager',
                export_model=True)
    model.eval(valid_dataset)
Ejemplo n.º 5
0
def main():
    data_loader=DataLoader()
    dataset=data_loader(data_dir=params['data_dir'], batch_size=8,training=True, sample=0.8)
    valid_dataset=data_loader(data_dir=params['data_dir'],batch_size=8, training=True, sample=0.2)

    model=Model(params=params, use_model=params['use_model'], use_loss='mse',use_optimizer='adam')  # model: seq2seq, tcn, transformer
    model.train(dataset,n_epochs=10,mode='eager',export_model=True)  # mode can choose eager or fit
    model.eval(valid_dataset)