0
$\begingroup$

I would like if someone could explain to me something. The architecture in YOLO from the Figure 3 in your YOLO paper https://pjreddie.com/media/files/papers/yolo.pdf is like this:

(448,448,3), (112,112,192), (56,56,256), (28,28,512), (14,14,1024),(7,7,1024),(7,7,1024), Dense(4096), (7,7,30)

I don't understand how to implement the last three parts, bolded ones If it is not the problem, I would appreciate if you help me understand that part. I use Keras and everything is OK for me to implement except those parts. I really don't know how to pass from (7,7,1024) to (7,7,1024) and also from Dense to (7,7,30).

$\endgroup$
1
$\begingroup$

You can use the Flatten and Reshape layers to go to Dense and back to HWC format. The last layers in keras would look like this:

7_7_1024_1 = ...  # The first (7,7,1024)
x = keras.layers.Conv2D(1024, 3, padding='same')(7_7_1024_1)
x = keras.layers.Flatten()(x)
x = keras.layers.Dense(4096)(x)
x = keras.layers.Dense(7 * 7 * 30)(x)
x = keras.layers.Reshape((7, 7, 30))(x)
$\endgroup$
  • $\begingroup$ Thank you very much for answer. There is only one thing I really don't understand. Input shape is (448,448,3) and then they got (112,112,192). I don't understand how they got that with 64 kernels of size (7,7) and stride = 2. $\endgroup$ – Alem Jun 26 '18 at 18:41
  • $\begingroup$ The first layer contains a conv stride 2 and max pool (2, 2) stride 2 which results in a 4x spatial reduction. $\endgroup$ – kenny Jun 27 '18 at 5:35
  • $\begingroup$ When we use conv stride = 2, shouldn't we get (448-7+2*0)/2 + 1 = 221.5 output dimension, instead of 224? This is what I didn't understand. I uderstand that from 224 with maxpooling we get 112, but I don't understand how we get 224. $\endgroup$ – Alem Jun 27 '18 at 10:53
  • $\begingroup$ I think I understand now. Padding is used here different from zero. Somewhere 1, somewhere 3. Fix me if I'm wrong. I used to code in Keras something like: model.add(something). Is there a way you could write your code in that way? $\endgroup$ – Alem Jun 27 '18 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.