import torch
from torch.nn import functional as F
from torch import nn
layer = nn.Conv2d(1, 3, kernel_size=3, stride=1, padding=0)
layer

x = torch.rand(1, 1, 28, 28)
x

out = layer.forward(x)
print("stride=1,padding=0:out.shape = ",out.shape)
layer = nn.Conv2d(1, 3, kernel_size=3, stride=1,padding=1)
out = layer.forward(x)
print("stride=1,padding=1:out.shape = ",out.shape)
layer = nn.Conv2d(1, 3, kernel_size=3, stride=2,padding=1)
out = layer.forward(x)
print("stride=2,padding=1:out.shape = ",out.shape)
print("-----Inner weight $ bias -----")
print("layer.weight = \n", layer.weight)
print("layer.weight.shape=",layer.weight.shape)
print("layer.bias.shape=",layer.bias.shape)

print("-----F.conv2d-----")
w = torch.rand(16, 3, 5, 5)
b = torch.rand(16)
x = torch.randn(1, 3