卷积的过程

#!/usr?bin/env/ python
# -*- coding:utf-8 -*-
# author: lai zheng laing
# datetime: 2020/10/29 15:27
# software: PyCharm
import torch
in_channels,out_channels = 5 , 10   # 输入通道,输出通道
width, height = 100,100            # 图片大小
kernel_size = 3                   # 卷积核大小
batch_size = 1                    # 每次取1张图片进行卷积
# 定义卷积层
input = torch.randn(batch_size,
                    in_channels,
                    width,
                    height)
# 卷积的生成
conv_layer = torch.nn.Conv2d(in_channels,
                             out_channels,
                             kernel_size=kernel_size)

output = conv_layer(input)

print(input.shape)
print(output.shape)
print(conv_layer.weight.shape)

结果

卷积的过程_第1张图片

你可能感兴趣的:(python,卷积,卷积神经网络)