tensorflow / models

Models and examples built with TensorFlow
Other
76.95k stars 45.8k forks source link

How can we use label_smooth in Tensorflow object detection API? #8770

Open gmt710 opened 4 years ago

gmt710 commented 4 years ago

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
pkulzc commented 4 years ago

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.

gmt710 commented 4 years ago

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

purvang3 commented 3 years ago

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)

ss880426 commented 2 months ago

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.