Training Our Classifier
Learn to train the classifier in this lesson.
We'll cover the following...
Training a classifier neural network is now really simple. That’s because we’ve done all the hard work setting up the dataset class and the neural network class.
Creating a neural network object
We first create a neural network from our Classifier
class.
Press + to interact
# create neural networkC = Classifier()
Training the network
To train the network, the code is again very simple:
Press + to interact
# train network on MNIST data setfor label, image_data_tensor, target_tensor in mnist_dataset:C.train(image_data_tensor, target_tensor)pass
The mnist_dataset inherits from PyTorch’s Dataset allowing us to work through all the training data with an elegant ...