Darknet53详细原理(含torch版源码)

这篇具有很好参考价值的文章主要介绍了Darknet53详细原理(含torch版源码)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Darknet53原理

        Darknet53是一个卷积神经网络模型,在2018年由Joseph Redmon在论文"YOLOv3: An Incremental Improvement"中提出,用于目标检测和分类任务。它是YOLOv3的核心网络模型,其设计思路是通过堆叠多个卷积和残差连接层来提高特征提取的效果。

        Darknet53包含53个卷积层和5个max-pooling层组成。Darknet53的结构可以被划分为三组:前段主要由卷积层和max-pooling层组成,中段主要由残差块组成,后段主要由全局平均池化层和全连接层组成。

        具体来说,前段的7个卷积层每层都是卷积核大小为3x3,步长为1x1的卷积,接着是5个max-pooling层。这部分的目的是将图像的空间信息不断缩小并增加深度。

        接下来是中段的残差块,由于YOLOv3的作者发现,在上述设计下,YOLOv3的学习非常的慢,于是便提出了一种名为"残差块(Residual Block)"的结构。残差块类似于一个短路,它可以让神经网络学习到“残差”,即当前输入和期望输出之间的差异。它使用残差结构来加速收敛、减少梯度消失的问题,以及提高精度。这种结构使得网络能够更好地学习输入图像中的特征,并且增强了模型的表达能力。网络框架图如下:

Darknet53详细原理(含torch版源码)

 

Darknet53详细原理(含torch版源码)

        Darknet53的输入为416x416像素大小的RGB图像,经过一系列卷积操作后,输出为13x13x1024的张量。这个张量可以传递给YOLOv3中的检测头,用于检测图像中的物体。

Darknet53网络框架的特点包括:

  1. 模型较浅:相比其他深度神经网络框架,Darknet53只有53层,因此训练速度快,性能高。

  2. 网络深度可扩展:使用残差结构,可以轻松地增加更多的卷积层来提高网络的性能。

  3. 参数量小:Darknet53的参数量比其他网络少很多,尤其是与ResNet等模型相比,这使得模型更快,更容易训练和优化。

  4. 高效推理:Darknet53使用低精度计算和并行计算技术,使得模型的推理速度很快,并且可以在低功耗设备上执行。

  5. 适用于大量类别的物体分类:Darknet53的优势在于学习图像特征,并可以高效地解决大量类别的物体分类问题。

        总的来说,Darknet53是一个非常有效的卷积神经网络,具有较高的准确性和效率,成为了现代计算机视觉任务中广泛使用的骨干网络之一,并且它已被广泛应用于计算机视觉领域的各种任务,包括图像分类、目标检测、人脸识别等。

Darknet53源码(torch版)

数据集运行代码时自动下载,如果网络比较慢,可以自行点击我分享的链接下载cifar数据集。

链接:百度网盘 
提取码:kd9a 

此代码是使用的GPU运行的,如果没有GPU导致运行失败,就把代码中的device、.to(device)删除,使用默认CPU运行。

如果GPU显存小导致运行报错,就将主函数main()里面的batch_size调小即可。


import torch
import torch.nn as nn
from torch.nn import modules
from torch.utils.data import DataLoader
from torchvision.datasets import CIFAR10
from torchvision.transforms import transforms
from torch.autograd import Variable


class ConvBnLeaky(modules.Module):
    def __init__(self,in_it,out_it,kernels,padding = 0,strides = 1):
        super(ConvBnLeaky, self).__init__()
        self.convs = nn.Sequential(
            nn.Conv2d(in_it,out_it,kernels,padding=padding,stride=strides),
            nn.BatchNorm2d(out_it),
            nn.LeakyReLU(0.1,True)
        )
    def forward(self,x):
        x = self.convs(x)
        return x
    pass
class Resnet_Block(modules.Module):
    def __init__(self,ch,num_block = 1):
        super(Resnet_Block, self).__init__()
        self.module_list = modules.ModuleList()
        for _ in range(num_block):
            resblock = nn.Sequential(
                ConvBnLeaky(ch,ch // 2,1),
                ConvBnLeaky(ch // 2,ch,kernels=3,padding=1)
            )
            self.module_list.append(resblock)
    def forward(self,x):
        for i in self.module_list:
            x = i(x) + x
        return x

class Darknet_53(modules.Module):
    def __init__(self,num_classes = 10):
        super(Darknet_53, self).__init__()
        self.later_1 = nn.Sequential(
            ConvBnLeaky(3,32,3,padding=1),
            ConvBnLeaky(32,64,3,padding=1,strides=2),
            Resnet_Block(64,1)
        )
        self.later_2 = nn.Sequential(
            ConvBnLeaky(64, 128, 3, padding=1,strides=2),
            Resnet_Block(128, 2)
        )
        self.later_3 = nn.Sequential(
            ConvBnLeaky(128, 256, 3, padding=1, strides=2),
            Resnet_Block(256, 8)
        )
        self.later_4 = nn.Sequential(
            ConvBnLeaky(256, 512, 3, padding=1, strides=2),
            Resnet_Block(512, 8)
        )
        self.later_5 = nn.Sequential(
            ConvBnLeaky(512, 1024, 3, padding=1, strides=2),
            Resnet_Block(1024, 4)
        )
        self.pool = nn.AdaptiveAvgPool2d((1,1))
        self.fc = nn.Linear(1024,num_classes)
    def forward(self,x):
        x = self.later_1(x)
        x = self.later_2(x)
        x = self.later_3(x)
        x = self.later_4(x)
        x = self.later_5(x)
        x = self.pool(x)
        x = torch.squeeze(x)
        x = self.fc(x)
        return x


def main():
    Root_file = 'cifar'
    train_data = CIFAR10(Root_file,train=True,transform = transforms.ToTensor())
    data = DataLoader(train_data,batch_size=64,shuffle=True)

    device = torch.device('cuda')
    net = Darknet_53().to(device)
    print(net)
    Cross = nn.CrossEntropyLoss().to(device)
    optimizer = torch.optim.Adam(net.parameters(),0.001)
    for epoch in range(10):
        for img,label in data:
            img = Variable(img).to(device)
            label = Variable(label).to(device)
            output = net.forward(img)
            loss = Cross(output,label)
            loss.backward()
            optimizer.zero_grad()
            optimizer.step()
            pre = torch.argmax(output,1)
            num = (pre == label).sum().item()
            acc = num / img.shape[0]
            loss_val = loss.item()
        print("epoch:",epoch)
        print("acc:",acc)
        print("loss:",loss_val)
    pass


if __name__ == '__main__':
    main()

 训练10个epoch的效果

效果图

Darknet53详细原理(含torch版源码) 

框架图

Darknet_53(
  (later_1): Sequential(
    (0): ConvBnLeaky(
      (convs): Sequential(
        (0): Conv2d(3, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        (1): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (2): LeakyReLU(negative_slope=0.1, inplace=True)
      )
    )
    (1): ConvBnLeaky(
      (convs): Sequential(
        (0): Conv2d(32, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
        (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (2): LeakyReLU(negative_slope=0.1, inplace=True)
      )
    )
    (2): Resnet_Block(
      (module_list): ModuleList(
        (0): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(64, 32, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
      )
    )
  )
  (later_2): Sequential(
    (0): ConvBnLeaky(
      (convs): Sequential(
        (0): Conv2d(64, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
        (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (2): LeakyReLU(negative_slope=0.1, inplace=True)
      )
    )
    (1): Resnet_Block(
      (module_list): ModuleList(
        (0): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(128, 64, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (1): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(128, 64, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
      )
    )
  )
  (later_3): Sequential(
    (0): ConvBnLeaky(
      (convs): Sequential(
        (0): Conv2d(128, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
        (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (2): LeakyReLU(negative_slope=0.1, inplace=True)
      )
    )
    (1): Resnet_Block(
      (module_list): ModuleList(
        (0): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(256, 128, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (1): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(256, 128, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (2): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(256, 128, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (3): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(256, 128, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (4): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(256, 128, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (5): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(256, 128, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (6): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(256, 128, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (7): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(256, 128, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
      )
    )
  )
  (later_4): Sequential(
    (0): ConvBnLeaky(
      (convs): Sequential(
        (0): Conv2d(256, 512, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
        (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (2): LeakyReLU(negative_slope=0.1, inplace=True)
      )
    )
    (1): Resnet_Block(
      (module_list): ModuleList(
        (0): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(512, 256, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (1): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(512, 256, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (2): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(512, 256, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (3): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(512, 256, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (4): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(512, 256, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (5): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(512, 256, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (6): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(512, 256, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (7): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(512, 256, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
      )
    )
  )
  (later_5): Sequential(
    (0): ConvBnLeaky(
      (convs): Sequential(
        (0): Conv2d(512, 1024, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
        (1): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (2): LeakyReLU(negative_slope=0.1, inplace=True)
      )
    )
    (1): Resnet_Block(
      (module_list): ModuleList(
        (0): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(1024, 512, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(512, 1024, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (1): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(1024, 512, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(512, 1024, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (2): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(1024, 512, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(512, 1024, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
        (3): Sequential(
          (0): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(1024, 512, kernel_size=(1, 1), stride=(1, 1))
              (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
          (1): ConvBnLeaky(
            (convs): Sequential(
              (0): Conv2d(512, 1024, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
              (1): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
              (2): LeakyReLU(negative_slope=0.1, inplace=True)
            )
          )
        )
      )
    )
  )
  (pool): AdaptiveAvgPool2d(output_size=(1, 1))
  (fc): Linear(in_features=1024, out_features=10, bias=True)
)文章来源地址https://www.toymoban.com/news/detail-498566.html

到了这里,关于Darknet53详细原理(含torch版源码)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • CV 经典主干网络 (Backbone) 系列: CSP-Darknet53

    CSP-Darknet53无论是其作为CV Backbone,还是说它在别的数据集上取得极好的效果。与此同时,它与别的网络的适配能力极强。这些特点都在宣告: CSP-Darknet53的重要性。 关于原理部分的内容请查看这里CV 经典主干网络 (Backbone) 系列: CSPNet 具体网络结构可以参考YOLO V3详解(一):网络

    2024年02月11日
    浏览(35)
  • 深度学习应用篇-计算机视觉-图像分类[2]:LeNet、AlexNet、VGG、GoogleNet、DarkNet模型结构、实现、模型特点详细介绍

    LeNet是最早的卷积神经网络之一 [1] ,其被提出用于识别手写数字和机器印刷字符。1998年,Yann LeCun第一次将LeNet卷积神经网络应用到图像分类上,在手写数字识别任务中取得了巨大成功。算法中阐述了图像中像素特征之间的相关性能够由参数共享的卷积操作所提取,同时使用

    2024年02月08日
    浏览(31)
  • 遗传算法原理详细讲解(算法+Python源码)

    博主介绍:✌专研于前后端领域优质创作者、本质互联网精神开源贡献答疑解惑、坚持优质作品共享、掘金/腾讯云/阿里云等平台优质作者、擅长前后端项目开发和毕业项目实战,深受全网粉丝喜爱与支持✌有需要可以联系作者我哦! 🍅文末获取源码联系🍅 👇🏻 精彩专栏

    2024年01月25日
    浏览(38)
  • VGG16详细原理(含tensorflow版源码)

            VGG16是一个经典的卷积神经网络模型,由牛津大学计算机视觉组(Visual Geometry Group)提出,用于参加2014年的ImageNet图像分类比赛。VGG16的名称来源于网络中包含的16个卷积层,其基本结构如下: 输入层:接收大小为224x224的RGB图像。 卷积层:共13个卷积层,每个卷积

    2024年02月05日
    浏览(28)
  • ResNet18详细原理(含tensorflow版源码)

            ResNet18是一个经典的深度卷积神经网络模型,由微软亚洲研究院提出,用于参加2015年的ImageNet图像分类比赛。ResNet18的名称来源于网络中包含的18个卷积层。 ResNet18的基本结构如下: 输入层:接收大小为224x224的RGB图像。 卷积层:共4个卷积层,每个卷积层使用3x3的卷积

    2024年02月04日
    浏览(26)
  • Vue项目中axios的原理(详细到源码)

    关于 axios 的基本使用,上篇文章已经有所涉及,这里再稍微回顾下: 构建一个 Axios 构造函数,核心代码为 request 导出 axios 实例 上述就已经能够实现 axios({ }) 这种方式的请求 下面是来实现下 axios.method() 这种形式的请求 将 Axios.prototype 上的方法搬运到 request 上 首先实现个工

    2024年01月20日
    浏览(66)
  • Springboot中SpringSecurity自动装配原理,源码级别绝对详细

    (1)Springboot有一个自动配置类 SecurityFilterAutoConfiguration , SecurityFilterAutoConfiguration 只要当项目中引入了SpringSecurity的相关jar包就会被自动加载。装载这个类是干嘛的呢? (2)如下图, SecurityFilterAutoConfiguration 自动配置类主要用于,当存在名字叫做\\\"springSecurityFilterChain\\\"的bea

    2024年02月05日
    浏览(39)
  • 详细解读Java中Map集合的底层原理(干货+源码解读)

    本文将为大家详细讲解Java中的Map集合,这是我们进行开发时经常用到的知识点,也是大家在学习Java中很重要的一个知识点,更是我们在面试时有可能会问到的问题。 文章较长,干货满满,建议大家收藏慢慢学习。文末有本文重点总结,主页有全系列文章分享。技术类问题,

    2024年02月06日
    浏览(71)
  • 【机器学习】详细解析Sklearn中的StandardScaler---原理、应用、源码与注意事项

    【机器学习】详细解析Sklearn中的StandardScaler—原理、应用、源码与注意事项 🌈 个人主页:高斯小哥 🔥 高质量专栏:Matplotlib之旅:零基础精通数据可视化、Python基础【高质量合集】、PyTorch零基础入门教程👈 希望得到您的订阅和支持~ 💡 创作高质量博文(平均质量分92+),分

    2024年03月20日
    浏览(37)
  • 【机器学习】进阶学习:详细解析Sklearn中的MinMaxScaler---原理、应用、源码与注意事项

    【机器学习】进阶学习:详细解析Sklearn中的MinMaxScaler—原理、应用、源码与注意事项 这篇文章的质量分达到了 97分 ,虽然满分是100分,但已经相当接近完美了。 请您耐心阅读,我相信您一定能从中获得不少宝贵的收获和启发~ 🌈 个人主页:高斯小哥 🔥 高质量专栏:Matp

    2024年03月12日
    浏览(41)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包