<prompt> Andika hati ya Python inayotumia PyTorch kutoa mafunzo kwa mtandao rahisi wa neva wa kubadilisha CNN kwenye mkusanyiko wa data wa CIFAR-10 kwa uainishaji wa picha.PLINFORMAT  <response>: kuagiza tochikuagiza tochivisionimport torchvision.transforms as transforms Pakia na urekebishe seti ya data ya CIFAR-10kubadilisha kubadilisha.Tunga transforms.RandomHorizontalFlip, inabadilisha.RandomCrop32, padding4, inabadilisha.ToTensor, hubadilisha.Sawazisha0.5, 0.5, 0.5, 0.5, 0.5, 0.5trainset torchvision.datasets.CIFAR10mizizi.data, treniKweli, pakuaKweli, badilishabadilishatrainloader torch.utils.data.DataLoaderseti ya treni, batch_size100, changanyaKweli, idadi_wafanyakazi2testset torchvision.datasets.CIFAR10mizizi.data, treniUongo, pakuaKweli, badilishabadilishatestloader torch.utils.data.DataLoadertestset, batch_size100, changanyaSi kweli, idadi_ya_wafanyakazi2madarasa ndege, gari, ndege, paka, kulungu, mbwa, chura, farasi, meli, lori Bainisha usanifu rahisi wa CNNagiza tochi.nn kama nnagiza tochi.nn.inafanya kazi kama Fclass Netnn.Module: def __init__binafsi: superNet, self.__init__ self.conv1 nn.Conv2d3, 6, 5 self.pool nn.MaxPool2d2, 2 self.conv2 nn.Conv2d6, 16, 5 self.fc1 nn.Linear16 5 5, 120 self.fc2 nn.Linear120, 84 self.fc3 nn.Linear84, 10 def mbele binafsi, x: x self.poolF.reluself.conv1x x self.poolF.reluself.conv2x x x.view-1, 16 5 5 x F.reluself.fc1x x F.reluself.fc2x x binafsi.fc3x kurudi xwavu Net Fafanua kazi ya upotezaji na kiboreshajiagiza tochi.optim kama borakigezo nn.CrossEntropyLossoptimizer optim.SGDnet.parameters, lr0.001, kasi0.9 Funza mtandaokwa epoch in range10: kitanzi juu ya seti ya data mara nyingi kukimbia_kupoteza 0.0 kwa i, data katika enumeratetrainloader, 0: pembejeo, lebo data optimizer.zero_grad matokeo wavupembejeo hasara kigezo matokeo, lebo hasara.nyuma optimizer.step running_loss loss.item ikiwa i 2000 1999: chapisha kila bachi 2000 ndogo chapad, 5d hasara: .3f Enzi 1, i 1, kukimbia_kupoteza 2000 kukimbia_kupoteza 0.0chapa Mafunzo Yaliyokamilika Pima mtandao kwenye data ya jaribiosahihi 0jumla 0na torch.no_grad: kwa data kwenye testloader: picha, lebo data matokeo wavupicha _, iliyotabiriwa tochi.maxoutputs.data, 1 jumla labels.size0 sahihi iliyotabiriwa lebo.jumla.kipengeeprintUsahihi wa mtandao kwenye picha 10000 za majaribio: d 100 sahihi jumla Hifadhi mfano uliofunzwatochi.savenet.state_dict, cifar_net.pth 