Total loss is NaN for object detection tf2.1
System information
Have I written custom code (as opposed to using example directory): https://github.com/tensorflow/models/tree/master/official/vision/detection changed strategy to "mirrored" to run in GPU/CPU, reduced batch size to 1 to start with minimum and changed location to my custom tfrecord. all other code unchanged. reference for other files : https://github.com/tensorflow/models/issues/8119 OS Platform and Distribution (e.g., Linux Ubuntu 16.04): ubuntu 18.04.2 LTS bionic TensorFlow backend (yes / no): yes TensorFlow version: 2.1.0 Keras version: 2.3.1 Python version: 3.7.3 CUDA/cuDNN version: N/A GPU model and memory: N/A Describe the current behavior: total loss is Nan and Error occurred when finalizing GeneratorDataset iterator
logs:
I0212 16:39:15.769866 139931759961920 distributed_executor.py:411] Training started
Traceback (most recent call last):
File "official/vision/detection/main.py", line 250, in dataset.cache().take(k).repeat(). You should use dataset.take(k).cache().repeat() instead.
2020-02-12 16:52:12.399724: W tensorflow/core/kernels/data/generator_dataset_op.cc:103] Error occurred when finalizing GeneratorDataset iterator: Cancelled: Operation was cancelled
Describe the expected behavior Calling model train should start training
Code to reproduce the issue: same code available in https://github.com/tensorflow/models/tree/master/official/vision/detection except for running it locally with strategy as "mirrored" and config file : https://github.com/tensorflow/models/issues/8119
If you restart the training from the same folder and restore the checkpoint, will the training go through? Or it consistently gets NaN. We do see some NaN issues and it has some randomness. @yeqingli
Hi Hongkun,
Thanks for your reply. I reduced the learning rate and that helped. But I am yet to fully train a model. Still half way.
Lakshmi
On Wed, Feb 12, 2020, 10:37 PM Hongkun Yu [email protected] wrote:
If you restart the training from the same folder and restore the checkpoint, will the training go through? Or it consistently gets NaN. We do see some NaN issues and it has some randomness. @yeqingli https://github.com/yeqingli
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tensorflow/models/issues/8131?email_source=notifications&email_token=ABZPWG72XCK4AK6QADK6W6TRCTE6ZA5CNFSM4KT6CGJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELTLUBA#issuecomment-585546244, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZPWG62D2BY7DB2JEW6EQLRCTE6ZANCNFSM4KT6CGJQ .
How can check accuracy or iou of the models for v training ?
Hi lamdawr,
I have same problem. In my case, "l2_regularization_loss" result was Nan. So total_loss also Nan.
Therefore, I temporary changed (official/vision/detection/modeling/retinanet_model.py line:111) total_loss = model_loss + l2_regularization_loss => total_loss = model_loss
Does the Object Detection API even work with TF2 (and Keras)?
@haimat This issue is about official/vision/detection (https://github.com/tensorflow/models/tree/master/official/vision/detection) and not the object detection API in research that is (not yet) compatible with tf>=2.0. Object detection models in official is only compatible with new versions of tensorflow.
@fellhorn Ahh, thanks for the clarification. Then that may be exactly what I am looking for. Unfortunately there is not much documentation (yet) on how to use official/vision/detection. Are there some more docs anywhere, or have you learned it by trial&error and looking at the code in the repo?
Object Detection API works with TF 2.x now. The official/vision/detection is deprecating and we are actively consolidating the works into official/vision/beta now.