Pytorch環境下搭建lenet5網路實作手寫數字識別
(文章采用cuda9.0+cudnn7.4+pytorch1.6環境)
資料集選用EMNIST dataset中的手寫資料集,參考鏈接如下:
資料集下載地址
代碼部分參考S.E作者的pytorch實作手寫英文字母識別,鏈接如下:
代碼部分
在原作者的基礎下將整個運行環境搭載在GPU上,實作代碼如下:
#查看GPU是否可用
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
#模型上GPU
cnn.to(device)
#資料上GPU
x=x.to(device)
y=y.to(device)
test_x=test_x.to(device)
test_y=test_y.to(device)
實作結果如下:


轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/302874.html
標籤:其他
