当前位置: 首页> 健康> 知识 > yolov5:Conv类参数量计算

yolov5:Conv类参数量计算

时间:2025/7/11 22:59:36来源:https://blog.csdn.net/a1367666195/article/details/140308216 浏览次数:0次

Conv是yolov5自定义的类,里边包含了卷积层、BN层和激活函数

class Conv(nn.Module):# Standard convolution with args(ch_in, ch_out, kernel, stride, padding, groups, dilation, activation)default_act = nn.SiLU()  # default activationdef __init__(self, c1, c2, k=1, s=1, p=None, g=1, d=1, act=True):"""Initializes a standard convolution layer with optional batch normalization and activation."""super().__init__()self.conv = nn.Conv2d(c1, c2, k, s, autopad(k, p, d), groups=g, dilation=d, bias=False)self.bn = nn.BatchNorm2d(c2)self.act = self.default_act if act is True else act if isinstance(act, nn.Module) else nn.Identity()

假设输入是[3, 32, 6, 2, 2](就是yolov5s第一层),即输入通道=3,输出通道=32,kernel_size=3,padding=2,stride=2

于是有:
参数量=conv2d参数+BN2d参数=3*6*6*32+32*2 = 3520

关键字:yolov5:Conv类参数量计算

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: