-
Notifications
You must be signed in to change notification settings - Fork 0
/
nn_conv2d.py
45 lines (31 loc) · 1.05 KB
/
nn_conv2d.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import torch
import torchvision
from torch import nn
from torch.nn import Conv2d
from torch.utils.data import DataLoader
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 Qianshi(nn.Module):
def __init__(self):
super(Qianshi, self).__init__()
self.conv1=Conv2d(in_channels=3,out_channels=6,kernel_size=3,stride=1,padding=0)
def forward(self,x):
x=self.conv1(x)
return x
qianshi=Qianshi()
print(qianshi)
writer=SummaryWriter("../Logs")
step=0
for data in dataloader:
imgs,targets=data
output=Qianshi(imgs)
# print(output.shape)
print(imgs.shape)
print(output.shape)
writer.add_image("input",imgs,step)
output=torch.reshape(output,(-1,3,30,30))
# -1表示不知道的话就填-1
writer.add_image("input",output,step)
step=step+1