Skip to Content
Deep Learning with PyTorch
book

Deep Learning with PyTorch

by Vishnu Subramanian
February 2018
Intermediate to advanced
262 pages
6h 59m
English
Packt Publishing
Content preview from Deep Learning with PyTorch

Training the model

The training steps for the model are the same as the previous example. Let's just look at the code to call the fit method and the results it generated:

train_losses , train_accuracy = [],[]val_losses , val_accuracy = [],[]for epoch in range(1,5):    epoch_loss, epoch_accuracy = fit(epoch,model,train_iter,phase='training')    val_epoch_loss , val_epoch_accuracy = fit(epoch,model,test_iter,phase='validation')    train_losses.append(epoch_loss)    train_accuracy.append(epoch_accuracy)    val_losses.append(val_epoch_loss)    val_accuracy.append(val_epoch_accuracy)

We ran the model for four epochs, which gave approximately 83% accuracy. Here are the results of running the model:

training loss is 0.59 and training accuracy is 16724/25000 66.9 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Deep Learning with PyTorch

Deep Learning with PyTorch

Eli Stevens, Thomas Viehmann, Luca Pietro Giovanni Antiga
Grokking Deep Learning

Grokking Deep Learning

Andrew W. Trask

Publisher Resources

ISBN: 9781788624336Supplemental Content