Mnist Classification with a Convolutional Neural Network using PyTorch

preview_player
Показать описание
In this video I will be showing how to write a CNN model to classify digits using the Mnist Dataset.

Рекомендации по теме
Комментарии
Автор

He changed some stuff and forgot to record I believe, so here is what I needed to change to get it working:
1) in the first cell do: import copy
2) in the "training function" cell he misspelled "accuracy" as "accurac" on the 3rd to last line so change it back to "accuracy"
3) in the "training function" cell, on the line "accuracy = float(validate(val_dl)" you need do this instead: "accuracy = float(validate(cnn, val_dl))"

nassermohammed
Автор

for people use cpu, modify validate part:
def validate(model, data):
correct = 0
for i, (images, labels) in enumerate(data):
images = images.to("cpu") # Move images to CPU
x = model(images)
value, pred = torch.max(x, 1)
correct += (pred == labels).sum().item()
accuracy = 100 * correct / len(data.dataset)
return accuracy

taohu
Автор

i got an error in the cell lenet=train(40, device=device)

nanaexo-l
Автор

Your smoke alarm has a low battery (11:30).

dannh
Автор

A minor mistake in the blog. In the architecture picture of the CNN, input image size is 32, with Conv2d(1, 6, 5, padding=2), the size of each 2d matrix after this convolution should be floor(32+2*padding-kernel size)/stride)+1=32. Not the number showed in the picture 28*28. However, the code is correct, because the actual input image size is 28*28, if you change 32*32 to 28*28 in the picture, everything is correct. All the numbers in the code will match.

tian
Автор

10:54 you show how to calculate the size of the first linear layer when the padding is equal to 0, but what if you are using padding equals to 'same', the equation is the same, or what do you change?

henriquekrever
Автор

i used the cpu, get an error here -> images = images.cuda(). when we are running on the cpu this line inside predict function is no longer required ryt ?

tmspeeches