jinyu121 / DW2TF

Darknet Weights to TensorFlow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pre-trained biases are ignored when batch_norm is present using tf-slim API

sjain-stanford opened this issue · comments

Issue

As per tf-slim conv2d documentation:

normalizer_fn: Normalization function to use instead of biases. If normalizer_fn is provided then biases_initializer and biases_regularizer are ignored and biases are not created nor added. default set to None for no normalizer function

In DW2TF, biases were being assigned using biases_initializer, which would silently get ignored when normalizer_fn was provided.

Examples

Conv without BN (biases are populated correctly)
without_bn

Conv with BN (biases are ignored)
with_bn

Solution

The correct way to handle this is to use the beta initializer of the normalizer for biases.

I've fixed this using tf.layers, where biases are added to convolution when BN is absent, or absorbed in beta of BN when present. PR is on the way.

Feel free to close after merging #4. Thanks.