Крошечный * .weights файл Yolo-v3 содержит меньше веса, чем ожидалось - PullRequest
0 голосов
/ 27 марта 2019

Я строю модель Yolo V3 Tiny в Tensorflow, и я хотел бы загрузить веса, предоставляемые самой Yolo .Я нашел здесь и, читая официальный код Yolo, могу прочитать yolov3-tiny.weights, отбрасывая первые 16 байтов, а затем читая оставшиеся байты, преобразовывая их в float32.

Теперь, yolov3-tiny.weights имеет 35,434,956 байт, поэтому (35,434,956-16) /4=8,858.735 чисел float32 и поэтому у меня должно быть 8,858,735 весов.

В любом случае, сводка моей крошечной сети yolov3 следующая:

>>> model.summary()
Model: "model"
__________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
Input (InputLayer)               [(None, 416, 416, 3) 0                                            
__________________________________________________________________________________________________
conv_1 (Conv2D)                 (None, 416, 416, 16) 448         Input[0][0]                       
__________________________________________________________________________________________________
norm_1 (BatchNormalizationV1)   (None, 416, 416, 16) 64          conv_1[0][0]                     
__________________________________________________________________________________________________
max_pooling2d (MaxPooling2D)    (None, 208, 208, 16) 0           norm_1[0][0]                     
__________________________________________________________________________________________________
conv_2 (Conv2D)                 (None, 208, 208, 32) 4640        max_pooling2d[0][0]              
__________________________________________________________________________________________________
norm_2 (BatchNormalizationV1)   (None, 208, 208, 32) 128         conv_2[0][0]                     
__________________________________________________________________________________________________
max_pooling2d_1 (MaxPooling2D)  (None, 104, 104, 32) 0           norm_2[0][0]                     
__________________________________________________________________________________________________
conv_3 (Conv2D)                 (None, 104, 104, 64) 18496       max_pooling2d_1[0][0]            
__________________________________________________________________________________________________
norm_3 (BatchNormalizationV1)   (None, 104, 104, 64) 256         conv_3[0][0]                     
__________________________________________________________________________________________________
max_pooling2d_2 (MaxPooling2D)  (None, 52, 52, 64)   0           norm_3[0][0]                     
__________________________________________________________________________________________________
conv_4 (Conv2D)                 (None, 52, 52, 128)  73856       max_pooling2d_2[0][0]            
__________________________________________________________________________________________________
norm_4 (BatchNormalizationV1)   (None, 52, 52, 128)  512         conv_4[0][0]                     
__________________________________________________________________________________________________
max_pooling2d_3 (MaxPooling2D)  (None, 26, 26, 128)  0           norm_4[0][0]                     
__________________________________________________________________________________________________
conv_5 (Conv2D)                 (None, 26, 26, 256)  295168      max_pooling2d_3[0][0]            
__________________________________________________________________________________________________
norm_5 (BatchNormalizationV1)   (None, 26, 26, 256)  1024        conv_5[0][0]                     
__________________________________________________________________________________________________
max_pooling2d_4 (MaxPooling2D)  (None, 13, 13, 256)  0           norm_5[0][0]                     
__________________________________________________________________________________________________
conv_6 (Conv2D)                 (None, 13, 13, 512)  1180160     max_pooling2d_4[0][0]            
__________________________________________________________________________________________________
norm_6 (BatchNormalizationV1)   (None, 13, 13, 512)  2048        conv_6[0][0]                     
__________________________________________________________________________________________________
max_pooling2d_5 (MaxPooling2D)  (None, 13, 13, 512)  0           norm_6[0][0]                     
__________________________________________________________________________________________________
conv_7 (Conv2D)                 (None, 13, 13, 1024) 4719616     max_pooling2d_5[0][0]            
__________________________________________________________________________________________________
norm_7 (BatchNormalizationV1)   (None, 13, 13, 1024) 4096        conv_7[0][0]                     
__________________________________________________________________________________________________
conv_8 (Conv2D)                 (None, 13, 13, 256)  262400      norm_7[0][0]                     
__________________________________________________________________________________________________
norm_8 (BatchNormalizationV1)   (None, 13, 13, 256)  1024        conv_8[0][0]                     
__________________________________________________________________________________________________
conv_11 (Conv2D)                (None, 13, 13, 128)  32896       norm_8[0][0]                     
__________________________________________________________________________________________________
norm_10 (BatchNormalizationV1)  (None, 13, 13, 128)  512         conv_11[0][0]                    
__________________________________________________________________________________________________
lambda_1 (Lambda)               (None, 26, 26, 128)  0           norm_10[0][0]                    
__________________________________________________________________________________________________
concatenate (Concatenate)       (None, 26, 26, 384)  0           lambda_1[0][0]                   
                                                                 norm_5[0][0]                     
__________________________________________________________________________________________________
conv_9 (Conv2D)                 (None, 13, 13, 512)  1180160     norm_8[0][0]                     
__________________________________________________________________________________________________
conv_12 (Conv2D)                (None, 26, 26, 256)  884992      concatenate[0][0]                
__________________________________________________________________________________________________
norm_9 (BatchNormalizationV1)   (None, 13, 13, 512)  2048        conv_9[0][0]                     
__________________________________________________________________________________________________
norm_11 (BatchNormalizationV1)  (None, 26, 26, 256)  1024        conv_12[0][0]                    
__________________________________________________________________________________________________
conv_10 (Conv2D)                (None, 13, 13, 255)  130815      norm_9[0][0]                     
__________________________________________________________________________________________________
conv_13 (Conv2D)                (None, 26, 26, 255)  65535       norm_11[0][0]                    
__________________________________________________________________________________________________
lambda (Lambda)                 (None, 507, 85)      0           conv_10[0][0]                    
__________________________________________________________________________________________________
lambda_2 (Lambda)               (None, 2028, 85)     0           conv_13[0][0]                    
__________________________________________________________________________________________________
concatenate_1 (Concatenate)     (None, 2535, 85)     0           lambda[0][0]                     
                                                                 lambda_2[0][0]                   
==================================================================================================
Total params: 8,861,918
Trainable params: 8,855,550
Non-trainable params: 6,368
__________________________________________________________________________________________________

и весит 8,861,918.(8.861.918-8.858.735) = 3183 параметров больше, чем в yolov3-tiny.weights.Я допустил какую-либо ошибку при создании сети или что-то упустил?

Спасибо.

1 Ответ

0 голосов
/ 23 мая 2019

Для каждого conv layer с нормализацией партии вы ошибаетесь, используя bias(b)yolo, conv layer с последующим batchnorm нет смещения.Например, для conv_1 layer правильный номер должен быть 3*3*3*16=432, а в вашей модели - 432+16=448.

...