Sunday, September 11, 2022

cnn filter, stride, paddling

# Create 10 random images of shape (1, 28, 28)
images = torch.rand(10, 1, 100, 50)

# Build 6 conv. filters
conv_filters = torch.nn.Conv2d(in_channels=1, out_channels=6, kernel_size=10, stride=4, padding=0)
print(output_feature.shape)
torch.Size([10, 6, 23, 11])

conv_filters = torch.nn.Conv2d(in_channels=1, out_channels=6, kernel_size=5, stride=4, padding=0) # Convolve the image with the filters output_feature = conv_filters(images) print(output_feature.shape)
torch.Size([10, 6, 24, 12])








conv_filters = torch.nn.Conv2d(in_channels=1, out_channels=6, kernel_size=5, stride=5, padding=0) # Convolve the image with the filters output_feature = conv_filters(images) print(output_feature.shape)
torch.Size([10, 6, 20, 10])





 



No comments:

Post a Comment