#!/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)
卷积的过程
最新推荐文章于 2024-05-29 11:25:24 发布