<jupyter_start><jupyter_text>$Convolution$$F(x,y)=\int{I(x^{'},y^{'})k(x-x^{'},y-y^{'})}dxdy$- $Input\_channels$- $Kernel\_channels$- $Kernel\_size$- $Stride$- $Padding$ $H_{out} = \frac{H_{in}+2\times padding[0]-dilation[0]\times(kernel\_size[0]-)-1}{stride[0]}+1$$W_{out} = \frac{W_{in}+2\times padding[1]-dilation[1]\times(kernel\_size[1]-)-1}{stride[1]}+1$<jupyter_code>import torch
import torch.nn as nn
from torch.nn import functional as F<jupyter_output><empty_output><jupyter_text>$nn.Conv2d$<jupyter_code># input_channels,kernel_channels,kernel_size,stride,padding

layer = nn.Conv2d(1,3,kernel_size = 3,stride = 1,padding = 0)
x = torch.rand(1,1,28,28)
out = layer.forward(x)
out.size()
layer = nn.Conv2d(1,3,kernel_size = 3,stride = 1,padding = 1)
out = layer.forward(x)
out.size()
layer = nn.Conv2d(1,3,kernel_size = 3,stride = 2,padding = 1)
out = layer.forward(x)
out.size()
out = layer(x)
out.size()<jupyter_output><empty_output><jupyter_text>$Inner\space weight\&bias$<jupyter_code>layer.weight
layer.weight.shape
layer.bias.shape<jupyter_output><empty_output><jupyter_text>$F.conv2d$<jupyter_code>w = torch.rand(16,3,5,5)
b = torch.rand(16)<jupyter_output><empty_output><jupyter_text>$Error$```pythonout = F.conv2d(x,w,b,stride = 1,padding = 1)---------------------------------------------------------------------------RuntimeError                              Traceback (most recent call last) in ----> 1 out = F.conv2d(x,w,b,stride = 1,padding = 1)RuntimeError: Given groups=1, weight of size [16, 3, 5, 5], expected input[1, 1, 28, 28] to have 3 channels, but got 1 channels instead```<jupyter_code>x = torch.randn(1,3,28,28)
out = F.conv2d(x,w,b,stride = 1,padding = 1)
out.size()
out = F.conv2d(x,w,b,stride = 2,padding = 2)
out.size()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.23167319529938443, 'fraction_numerical': 0.04476776720761052, 'mean_word_length': 4.8431372549019605, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '357148', 'license': 'MIT', 'n_tokens_mistral': 754, 'n_tokens_neox': 705, 'n_words': 106, 'path': 'Pytorch/Pytorch_learn_by_dragen1860/lesson34-卷积神经网络.ipynb', 'repo_name': 'tsuirak/skills', 'size': '1787'}