22.02.2024 Views

Daniel Voigt Godoy - Deep Learning with PyTorch Step-by-Step A Beginner’s Guide-leanpub

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Model Configuration & Training

Model Configuration

1 torch.manual_seed(21)

2 model = SquareModelGRU(n_features=2, hidden_dim=2, n_outputs=1)

3 loss = nn.BCEWithLogitsLoss()

4 optimizer = optim.Adam(model.parameters(), lr=0.01)

Model Training

1 sbs_gru = StepByStep(model, loss, optimizer)

2 sbs_gru.set_loaders(train_loader, test_loader)

3 sbs_gru.train(100)

fig = sbs_gru.plot_losses()

Figure 8.19 - Losses—SquareModelGRU

Cool—the loss decreased much quicker now, and all it takes is switching from RNN

to GRU.

"The sensation you feel is the quickening."

Ramirez

StepByStep.loader_apply(test_loader, sbs_gru.correct)

636 | Chapter 8: Sequences

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!