Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to train the ESN in online mode? #21

Open
ruitang-git opened this issue Jan 10, 2024 · 0 comments
Open

How to train the ESN in online mode? #21

ruitang-git opened this issue Jan 10, 2024 · 0 comments

Comments

@ruitang-git
Copy link

Using svd to train mackey-glass data, the error can decrease to 3.2e-11.

While I change to gradient descent, after 100 epochs, the error becomes about 1e-4. I have no idea about how to tune paramters to make the error drop to that low. Can anybody helps?

    ## transform into dataset class
    train_dataset = torch.utils.data.dataset.TensorDataset(trX, trY)
    test_dataset = torch.utils.data.dataset.TensorDataset(tsX, tsY)

    ## transform dataset into dataloader
    train_dataloader = torch.utils.data.DataLoader(train_dataset, batch_size=1024, shuffle=False)
    test_dataloader = torch.utils.data.DataLoader(test_dataset, batch_size=1024, shuffle=False)


    model = ESN(input_size, hidden_size, output_size, readout_training='gd')
    model.to(device)
    opt = torch.optim.Adam(model.parameters(), lr=0.01, weight_decay=0)
    epochs = 100
    for epoch in range(epochs):
        hidden = None
        train_loss = 0
        for batch in train_dataloader:
            x, y = batch
            x = x.to(device)
            y = y.to(device)
            output, hidden = model(x, washout, hidden)
            loss = loss_fcn(output, y[washout[0]:])
            opt.zero_grad()
            loss.backward()
            opt.step()
            train_loss += loss.item()
        print("Training error:", train_loss/len(train_dataloader))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant