[DeepLab] Loss is inf or nan using Pascal VOC 2012 Dataset
I just wanna try train the dataset from pascal voc using checkpoint deeplabv3_pascal_train_aug but always fail with this issue. I already follow all steps from (http://www.programmersought(dot)com/article/4188126074/;jsessionid=D5E2DD60EB3053E982BEA4EF5FB2ADEA) and (https://www.analyticsvidhya(dot)com/blog/2019/02/tutorial-semantic-segmentation-google-deeplab/).
System information
- What is the top-level directory of the model you are using: Deeplab
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10
- TensorFlow version (use command below):tensorflow-gpu 1.15
- CUDA/cuDNN version: CUDA 10
- GPU model and memory: GTX 1060 6GB
- Exact command to reproduce:
This is my script for running my train
python train.py
--logtostderr
--training_number_of_steps=90000
--train_split="train"
--model_variant="xception_65"
--atrous_rates=6 --atrous_rates=12 --atrous_rates=18
--output_stride=16
--decoder_output_stride=4
--train_crop_size=513,513
--train_batch_size=1
--dataset="pascal_voc_seg"
--dataset_dir="D:\FUNFMN\ta3\models\research\deeplab\datasets\Database\tf_record"
--tf_initial_checkpoint="D:\FUNFMN\ta3\models\research\deeplab\checkpoint\deeplabv3_pascal_train_aug\model.ckpt"
--train_logdir="D:\FUNFMN\ta3\models\research\deeplab\datasets\Database\train_logdir"
--initialize_last_layer=False
--last_layers_contain_logits_only=True
--fine_tune_batch_norm=False
and this my error
Describe the problem
I0131 01:13:28.899782 24364 supervisor.py:1099] global_step/sec: 0 INFO:tensorflow:global step 10: loss = 0.6717 (0.323 sec/step) I0131 01:13:33.996986 16004 learning.py:507] global step 10: loss = 0.6717 (0.323 sec/step) INFO:tensorflow:global step 20: loss = 1.5686 (0.325 sec/step) I0131 01:13:37.344420 16004 learning.py:507] global step 20: loss = 1.5686 (0.325 sec/step) INFO:tensorflow:global step 30: loss = 0.1612 (0.312 sec/step) I0131 01:13:40.560513 16004 learning.py:507] global step 30: loss = 0.1612 (0.312 sec/step) INFO:tensorflow:global step 40: loss = 0.3794 (0.384 sec/step) I0131 01:13:44.067640 16004 learning.py:507] global step 40: loss = 0.3794 (0.384 sec/step) INFO:tensorflow:global step 50: loss = 0.1586 (0.329 sec/step) I0131 01:13:47.300520 16004 learning.py:507] global step 50: loss = 0.1586 (0.329 sec/step) INFO:tensorflow:global step 60: loss = 0.2120 (0.313 sec/step) I0131 01:13:50.652518 16004 learning.py:507] global step 60: loss = 0.2120 (0.313 sec/step) INFO:tensorflow:global step 70: loss = 0.1773 (0.328 sec/step) I0131 01:13:53.870276 16004 learning.py:507] global step 70: loss = 0.1773 (0.328 sec/step) INFO:tensorflow:global step 80: loss = 0.2059 (0.313 sec/step) I0131 01:13:57.196119 16004 learning.py:507] global step 80: loss = 0.2059 (0.313 sec/step) INFO:tensorflow:global step 90: loss = 0.4544 (0.311 sec/step) I0131 01:14:00.384758 16004 learning.py:507] global step 90: loss = 0.4544 (0.311 sec/step) INFO:tensorflow:global step 100: loss = 0.2439 (0.320 sec/step) I0131 01:14:03.659304 16004 learning.py:507] global step 100: loss = 0.2439 (0.320 sec/step) INFO:tensorflow:global step 110: loss = 2.0604 (0.328 sec/step) I0131 01:14:06.906721 16004 learning.py:507] global step 110: loss = 2.0604 (0.328 sec/step) INFO:tensorflow:global step 120: loss = 3.6568 (0.324 sec/step) I0131 01:14:10.141874 16004 learning.py:507] global step 120: loss = 3.6568 (0.324 sec/step) INFO:tensorflow:global step 130: loss = 0.1893 (0.328 sec/step) I0131 01:14:13.533044 16004 learning.py:507] global step 130: loss = 0.1893 (0.328 sec/step) INFO:tensorflow:global step 140: loss = 0.8074 (0.321 sec/step) I0131 01:14:16.729441 16004 learning.py:507] global step 140: loss = 0.8074 (0.321 sec/step) INFO:tensorflow:global step 150: loss = 0.1688 (0.311 sec/step) I0131 01:14:19.898051 16004 learning.py:507] global step 150: loss = 0.1688 (0.311 sec/step) INFO:tensorflow:global step 160: loss = 0.4113 (0.315 sec/step) I0131 01:14:23.207805 16004 learning.py:507] global step 160: loss = 0.4113 (0.315 sec/step) INFO:tensorflow:global step 170: loss = 0.4488 (0.316 sec/step) I0131 01:14:26.409547 16004 learning.py:507] global step 170: loss = 0.4488 (0.316 sec/step) INFO:tensorflow:global step 180: loss = 1.9576 (0.320 sec/step) I0131 01:14:29.666006 16004 learning.py:507] global step 180: loss = 1.9576 (0.320 sec/step) INFO:tensorflow:global step 190: loss = 0.1410 (0.329 sec/step) I0131 01:14:32.875228 16004 learning.py:507] global step 190: loss = 0.1410 (0.329 sec/step) INFO:tensorflow:global step 200: loss = 0.1631 (0.321 sec/step) I0131 01:14:36.106254 16004 learning.py:507] global step 200: loss = 0.1631 (0.321 sec/step) INFO:tensorflow:Error reported to Coordinator: <class 'tensorflow.python.framework.errors_impl.InvalidArgumentError'>, Loss is inf or nan. : Tensor had NaN values [[node CheckNumerics (defined at D:\Anaconda3\envs\dlv3p2\lib\site-packages\tensorflow_core\python\framework\ops.py:1748) ]]
Original stack trace for 'CheckNumerics':
File "train.py", line 464, in
I0131 01:14:38.084058 16004 coordinator.py:224] Error reported to Coordinator: <class 'tensorflow.python.framework.errors_impl.InvalidArgumentError'>, Loss is inf or nan. : Tensor had NaN values [[node CheckNumerics (defined at D:\Anaconda3\envs\dlv3p2\lib\site-packages\tensorflow_core\python\framework\ops.py:1748) ]] .
I am training deeplab on custom dataset and it is causing same issue..
INFO:tensorflow:Saving checkpoints for 0 into E:\mypython\Lib\site-packages\tensorflow\models\research\deeplab\datasets\train\model.ckpt. Total loss is :[0.140642926] Total loss is :[0.140642881] INFO:tensorflow:global_step/sec: 1.11037 Total loss is :[0.140642926] INFO:tensorflow:global_step/sec: 2.71813 Total loss is :[0.140643507] INFO:tensorflow:global_step/sec: 2.70563 Total loss is :[0.140675873] INFO:tensorflow:global_step/sec: 2.69324 Total loss is :[nan] INFO:tensorflow:global_step/sec: 2.70379 Total loss is :[nan] INFO:tensorflow:global_step/sec: 2.70343 Total loss is :[nan] INFO:tensorflow:global_step/sec: 2.71518 Total loss is :[nan] INFO:tensorflow:global_step/sec: 2.72926 Total loss is :[nan]
Traceback (most recent call last): File "E:\mypython\lib\site-packages\tensorflow\python\client\session.py", line 1334, in _do_call return fn(*args) File "E:\mypython\lib\site-packages\tensorflow\python\client\session.py", line 1319, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "E:\mypython\lib\site-packages\tensorflow\python\client\session.py", line 1407, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: Nan in summary histogram for: xception_65/middle_flow/block1/unit_8/xception_module/separable_conv1_depthwise/BatchNorm/beta_1 [[{{node xception_65/middle_flow/block1/unit_8/xception_module/separable_conv1_depthwise/BatchNorm/beta_1}}]] [[{{node Mean_382}}]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "deeplab/train.py", line 513, in
Caused by op 'xception_65/middle_flow/block1/unit_8/xception_module/separable_conv1_depthwise/BatchNorm/beta_1', defined at:
File "deeplab/train.py", line 513, in
InvalidArgumentError (see above for traceback): Nan in summary histogram for: xception_65/middle_flow/block1/unit_8/xception_module/separable_conv1_depthwise/BatchNorm/beta_1 [[node xception_65/middle_flow/block1/unit_8/xception_module/separable_conv1_depthwise/BatchNorm/beta_1 (defined at deeplab/train.py:322) ]] [[node Mean_382 (defined at deeplab/train.py:302) ]]
@RajatGarg45 I think its a different issue, u have problem with ur memory GPU computing, try change fine_tune_batch_norm to false in train.py.
btw i found the problem for my issue. I dont know the detail but it's come from my tfrecords after running pascal_voc2012_data.py for convert the data. When i using tfrecord from sh download_and_convert_voc2012.sh it works normally.
@fmanadeprasetyo I have already set it to false and I am preparing my tfrecord files with shell script only.
I was able to resolve the issue. The problem was with my training dataset.