keras-yolo2
keras-yolo2 copied to clipboard
Why randomize weights of the last layer in Yolo Step-by-Step.ipynb?
Hi, First of all, thank you for sharing this amazing work. Could you explain, why you do this operation?
layer = model.layers[-4] # the last convolutional layer
weights = layer.get_weights()
new_kernel = np.random.normal(size=weights[0].shape)/(GRID_H*GRID_W)
new_bias = np.random.normal(size=weights[1].shape)/(GRID_H*GRID_W)
layer.set_weights([new_kernel, new_bias])
Thanks in advance.
Recall that we are using a pretrained model which was trained on a large data set. We are using this model via transfer learning. To do this, we need to customize the pretrained model. Since we have a small data set (e.g. the raccoon data set), we are going with feature-extraction approach.
The fine-extraction approach involves adding a new classifier on top of the pretrained model. And recall that when we train a model from scratch we initialize our weights to random values.
You can learn more about both types of transfer learning on the TensorFlow Tutorial's page: https://www.tensorflow.org/tutorials/images/transfer_learning