Skip to main content
. 2021 May 12;21(10):3374. doi: 10.3390/s21103374
Algorithm 1. Approach of pruning channel and layer in YOLOv4
Input: N layers and M shortcut layers of YOLOv4, channel pruning rate α and layer pruning t
Output: The remaining layers after pruning
Sparsity training N layers and M shortcut layers and get γki of the k-th channel of i-th layer
Sort γki of N layers and M shortcut layers from small to large and then get array W
Threshold t=Wintα·lenW
for i=1 to N do
if γk=1,2,i<t Remove these channels k=1,2, of i-th layer
end for
A~F is shown as Figure 3. Ai is the A layer of i-th shortcut layer structure.
for i=1 to M do
  if γk=1,2,i<t
Mark k=1,2, which is the index of channels of Ai layer
for j=Ai to [Ai, Ci, Fi] do
  Remove k=1,2, channels of j layer
end for
end for
Evalute the mean value ms=1,2,,23 of γk=1,2,i for each M shortcut layers, then sort m from small to large
for i=1 to t do
Get the index of shortcut layer s=msi Remove Cs,Ds and Es layers
end for