Changes

Jump to: navigation, search

DPS921/PyTorch: Convolutional Neural Networks

320 bytes added, 17:39, 29 November 2020
Implementation of a Neural Network
net = Net()
''' 5. Test our neural network with some randomized values representing a 1 dimensional tensor of pixel values of 28 by 28 pixel image.
''' print the output of the test and ensure that the resultant is a tensor with numerical 10 values.
X = torch.rand((28,28)) X = X.view(-1, 28*28) output = net(X) print(output) ''' 56. Use an optimizer to train the neural network. By passing the 1-dimensional tensor of pixel maps of each image in the training
''' data set to the optimizer, it allows the optimizer to update the weight value of each of the layers in our neural network.
print(loss)
''' 67. Iterate through the trainset data again to verify current accuracy rating of our neural network using the testset data set.
correct = 0
print("Accuracy: ", round(correct/total, 3))
''' 78. View the data at index of 0 in the training data set as 28 x 28 Image, Making sure to import 'matplotlib'.
import matplotlib.pyplot as plt
plt.show()
''' 89. Test the trained neural network to check whether the digit value shown in the image is in fact the number
''' the neural network determined it to be.

Navigation menu