一、前言
在B站学习pytorch,看的是小土堆up主的视频,历经不少艰难险阻当学到“神经网络-卷积层这节内容时,代码和视频中的完全像同,但是我的却出现了NotImplementedError的报错,百思不得其解,枯了,希望能有人帮我看看
二、我的代码
代码如下(示例):
import torch
from torch import nn
from torch.nn import Conv2d
from torch.utils.data import DataLoader
import torchvision
from torch.utils.tensorboard import SummaryWriter
dataset = torchvision.datasets.CIFAR10("../data",train=False,transform=torchvision.transforms.ToTensor(),download=True)
dataloader = DataLoader(dataset,batch_size=64)
class Tudui(nn.Module):
def __init__(self):
super(Tudui,self).__init__()
self.conv1 = Conv2d(in_channels=3,out_channels=6,kernel_size=3,stride=1,padding=0)
def foward(self,x):
x = self.conv1(x)
return x
tudui = Tudui()
#print(tudui)
writer = SummaryWriter("logs")
step = 0
for data in dataloader:
imgs,targets = data
output = tudui(imgs)
writer.add_image("input",imgs,step)
torch.reshape(output,(-1,3,30,30))
writer.add_image("output",output,step)
step = step+1
三、我的错误
希望有好心人捞捞我这个大一小白,万分感谢
|