models icon indicating copy to clipboard operation
models copied to clipboard

How can we use label_smooth in Tensorflow object detection API?

Open gmt710 opened this issue 5 years ago • 4 comments

How can we use label smoothing in Tensorflow object detection API? I want to use label smoothing, but I don't how to configure. I have two guesses:

  1. Train with --label_smooth=0.1
  2. Modify in losses.py file

gmt710 avatar Jul 02 '20 03:07 gmt710

Tensorflow object detection API is a config based framework so "--label_smooth=0.1" would not work. label smoothing is not exposed or implemented in our code yet. But it's pretty simple if you want to do it by yourselves. You could modify the _computes_loss fn of this class.

pkulzc avatar Jul 11 '20 01:07 pkulzc

Thx. I'll try it when I have time.

gmt710 avatar Jul 11 '20 02:07 gmt710

Not sure if you still find it useful. add following code in above mentioned class by @pkulzc.

label_smoothing = 0.1 factor = tf.constant(label_smoothing) target_tensor *= (1 - factor) target_tensor += (factor / target_tensor.shape[2].value)

purvang3 avatar Apr 26 '21 20:04 purvang3

Not sure if you still find it useful. add following code in above mentioned class by @pkulzc.

label_smoothing = 0.1 factor = tf.constant(label_smoothing) target_tensor *= (1 - factor) target_tensor += (factor / target_tensor.shape[2].value)

Is this valid? After I followed the instructions, nothing changed. Even if I deleted the entire function, I could still train normally.

ss880426 avatar Jul 01 '24 05:07 ss880426