models icon indicating copy to clipboard operation
models copied to clipboard

Shape error when using object detection API

Open hanzy123 opened this issue 9 years ago • 11 comments

My training always interrupted after few steps,The output is here:

INFO:tensorflow:Scale of 0 disables regularizer.
INFO:tensorflow:Scale of 0 disables regularizer.
INFO:tensorflow:Scale of 0 disables regularizer.
INFO:tensorflow:Scale of 0 disables regularizer.
INFO:tensorflow:Scale of 0 disables regularizer.
INFO:tensorflow:Scale of 0 disables regularizer.
INFO:tensorflow:Summary name Learning Rate is illegal; using Learning_Rate instead.
INFO:tensorflow:Summary name /clone_loss is illegal; using clone_loss instead.
/root/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gradients_impl.py:93: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory.
  "Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
2017-08-02 10:31:13.608186: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-08-02 10:31:13.608209: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-08-02 10:31:13.608214: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-08-02 10:31:13.608218: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-08-02 10:31:13.608222: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
2017-08-02 10:31:13.712671: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2017-08-02 10:31:13.713150: I tensorflow/core/common_runtime/gpu/gpu_device.cc:887] Found device 0 with properties:
name: GeForce GTX 1080
major: 6 minor: 1 memoryClockRate (GHz) 1.8475
pciBusID 0000:01:00.0
Total memory: 7.92GiB
Free memory: 7.81GiB
2017-08-02 10:31:13.713179: I tensorflow/core/common_runtime/gpu/gpu_device.cc:908] DMA: 0
2017-08-02 10:31:13.713186: I tensorflow/core/common_runtime/gpu/gpu_device.cc:918] 0:   Y
2017-08-02 10:31:13.713193: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0)
INFO:tensorflow:Restoring parameters from object_detection/Human_detection/output/model.ckpt-0
2017-08-02 10:31:22.372886: I tensorflow/core/common_runtime/simple_placer.cc:669] Ignoring device specification /device:GPU:0 for node 'prefetch_queue_Dequeue' because the input edge from 'prefetch_queue' is a reference connection and already has a device field set to /device:CPU:0
INFO:tensorflow:Starting Session.
INFO:tensorflow:Starting Queues.
INFO:tensorflow:global_step/sec: 0
INFO:tensorflow:global step 1: loss = 1.6937 (37.98 sec/step)
2017-08-02 10:33:23.330706: I tensorflow/core/common_runtime/gpu/pool_allocator.cc:247] PoolAllocator: After 2749 get requests, put_count=2117 evicted_count=1000 eviction_rate=0.472367 and unsatisfied allocation rate=0.630047
2017-08-02 10:33:23.330754: I tensorflow/core/common_runtime/gpu/pool_allocator.cc:259] Raising pool_size_limit_ from 100 to 110
INFO:tensorflow:global step 2: loss = 1.9736 (0.32 sec/step)
INFO:tensorflow:global step 3: loss = 1.6014 (0.87 sec/step)
INFO:tensorflow:global step 4: loss = 1.3160 (0.35 sec/step)
INFO:tensorflow:global step 5: loss = 1.0027 (0.42 sec/step)
INFO:tensorflow:global step 6: loss = 0.6841 (0.28 sec/step)
INFO:tensorflow:global step 7: loss = 0.5660 (0.83 sec/step)
INFO:tensorflow:global step 8: loss = 0.5574 (0.71 sec/step)
INFO:tensorflow:global step 9: loss = 0.4658 (0.25 sec/step)
INFO:tensorflow:global step 10: loss = 0.4297 (0.27 sec/step)
INFO:tensorflow:global step 11: loss = 0.3972 (0.29 sec/step)
INFO:tensorflow:global step 12: loss = 0.3471 (0.93 sec/step)
2017-08-02 10:33:28.848779: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Incompatible shapes: [1,62,4] vs. [1,64,4]
	 [[Node: gradients/Loss/BoxClassifierLoss/Loss/sub_grad/BroadcastGradientArgs = BroadcastGradientArgs[T=DT_INT32, _device="/job:localhost/replica:0/task:0/gpu:0"](gradients/Loss/BoxClassifierLoss/Loss/sub_grad/Shape, gradients/Loss/BoxClassifierLoss/Loss/sub_grad/Shape_1)]]
2017-08-02 10:33:28.850346: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Incompatible shapes: [1,62,4] vs. [1,64,4]
	 [[Node: gradients/Loss/BoxClassifierLoss/Loss/sub_grad/BroadcastGradientArgs = BroadcastGradientArgs[T=DT_INT32, _device="/job:localhost/replica:0/task:0/gpu:0"](gradients/Loss/BoxClassifierLoss/Loss/sub_grad/Shape, gradients/Loss/BoxClassifierLoss/Loss/sub_grad/Shape_1)]]
2017-08-02 10:33:28.850387: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Incompatible shapes: [1,62,4] vs. [1,64,4]
	 [[Node: gradients/Loss/BoxClassifierLoss/Loss/sub_grad/BroadcastGradientArgs = BroadcastGradientArgs[T=DT_INT32, _device="/job:localhost/replica:0/task:0/gpu:0"](gradients/Loss/BoxClassifierLoss/Loss/sub_grad/Shape, gradients/Loss/BoxClassifierLoss/Loss/sub_grad/Shape_1)]]
INFO:tensorflow:Error reported to Coordinator: <class 'tensorflow.python.framework.errors_impl.InvalidArgumentError'>, Incompatible shapes: [1,62,4] vs. [1,64,4]
	 [[Node: gradients/Loss/BoxClassifierLoss/Loss/sub_grad/BroadcastGradientArgs = BroadcastGradientArgs[T=DT_INT32, _device="/job:localhost/replica:0/task:0/gpu:0"](gradients/Loss/BoxClassifierLoss/Loss/sub_grad/Shape, gradients/Loss/BoxClassifierLoss/Loss/sub_grad/Shape_1)]]

hanzy123 avatar Aug 02 '17 10:08 hanzy123

...
...which was originally created as op 'Loss/BoxClassifierLoss/Loss/sub', defined at:
  File "object_detection/train.py", line 198, in <module>
    tf.app.run()
[elided 1 identical lines from previous traceback]
  File "object_detection/train.py", line 194, in main
    worker_job_name, is_chief, FLAGS.train_dir)
  File "/root/dl-data/github/models/object_detection/trainer.py", line 192, in train
    clones = model_deploy.create_clones(deploy_config, model_fn, [input_queue])
  File "/root/dl-data/github/models/slim/deployment/model_deploy.py", line 193, in create_clones
    outputs = model_fn(*args, **kwargs)
  File "/root/dl-data/github/models/object_detection/trainer.py", line 133, in _create_losses
    losses_dict = detection_model.loss(prediction_dict)
  File "/root/dl-data/github/models/object_detection/meta_architectures/faster_rcnn_meta_arch.py", line 1265, in loss
    groundtruth_classes_with_background_list))
  File "/root/dl-data/github/models/object_detection/meta_architectures/faster_rcnn_meta_arch.py", line 1421, in _loss_box_classifier
    batch_reg_targets, weights=batch_reg_weights) / normalizer
  File "/root/dl-data/github/models/object_detection/core/losses.py", line 71, in __call__
    return self._compute_loss(prediction_tensor, target_tensor, **params)
  File "/root/dl-data/github/models/object_detection/core/losses.py", line 157, in _compute_loss
    diff = prediction_tensor - target_tensor
  File "/root/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 821, in binary_op_wrapper
    return func(x, y, name=name)
  File "/root/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 2627, in _sub
    result = _op_def_lib.apply_op("Sub", x=x, y=y, name=name)
  File "/root/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 768, in apply_op
    op_def=op_def)

InvalidArgumentError (see above for traceback): Incompatible shapes: [1,62,4] vs. [1,64,4]
	 [[Node: gradients/Loss/BoxClassifierLoss/Loss/sub_grad/BroadcastGradientArgs = BroadcastGradientArgs[T=DT_INT32, _device="/job:localhost/replica:0/task:0/gpu:0"](gradients/Loss/BoxClassifierLoss/Loss/sub_grad/Shape, gradients/Loss/BoxClassifierLoss/Loss/sub_grad/Shape_1)]]
	 [[Node: gradients/FirstStageFeatureExtractor/resnet_v1_101/resnet_v1_101/block3/unit_9/bottleneck_v1/conv3/BatchNorm/Reshape_1_grad/Reshape/_3783 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_19221_gradients/FirstStageFeatureExtractor/resnet_v1_101/resnet_v1_101/block3/unit_9/bottleneck_v1/conv3/BatchNorm/Reshape_1_grad/Reshape", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

hanzy123 avatar Aug 02 '17 10:08 hanzy123

Why i get the error ? Thanks!

hanzy123 avatar Aug 02 '17 10:08 hanzy123

Please provide details about what platform you are using (operating system, architecture). Also include your TensorFlow version. Also, did you compile from source or install a binary? Make sure you also include the exact command if possible to produce the output included in your test case. If you are unclear what to include see the issue template displayed in the Github new issue template.

We ask for this in the issue submission template, because it is really difficult to help without that information. Thanks!

shivaniag avatar Aug 03 '17 01:08 shivaniag

My platform is Ubuntu16.04 and using Nvidia-smi_375.66,My Cuda version is Cuda8.0.My tensorflow version is 1.1.0

hanzy123 avatar Aug 03 '17 01:08 hanzy123

I have the same error as #1618 but i can't deal it after clearing all checkpoint as he said

hanzy123 avatar Aug 03 '17 01:08 hanzy123

I fixed the problem.On my side,I made bad image/object/class/text and image/object/class/label.After I correct the text and label, the problem gone

hanzy123 avatar Aug 03 '17 06:08 hanzy123

@hanzy123 Facing the same issue. What exactly did you changed?

Sharathnasa avatar Aug 22 '17 06:08 Sharathnasa

@Sharathnasa Maybe you have the bad training data,In my case, i set the classes_text = 1, classes =1 at the begining and get the error.After i set the classes_text=[1,1,1,...,1] and classes = [1,1,1,...,1] ,It worked!

hanzy123 avatar Aug 23 '17 00:08 hanzy123

I encountered the same error. I found the error caused by wrongly defining the tfrecords data structures. I wrongly write the key like this:

 'image/object/box/class/text': dataset_util.bytes_list_feature(classes_text),
 'image/object/box/class/label': dataset_util.int64_list_feature(classes),

When I changed to the following, the error disappears.

 'image/object/class/text': dataset_util.bytes_list_feature(classes_text),
 'image/object/class/label': dataset_util.int64_list_feature(classes),

auroua avatar Sep 05 '17 01:09 auroua

I have this issue. This is the error I'm getting. I believe that this is because of some bad training data shapes. I was wondering how to narrow down on which parameter is giving this error.

InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [9] rhs shape= [273] [[Node: save/Assign_2 = Assign[T=DT_FLOAT, _class=["loc:@BoxPredictor_0/ClassPredictor/biases"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](BoxPredictor_0/ClassPredictor/biases, save/RestoreV2:2)]]

Manish-rai21bit avatar Aug 15 '18 17:08 Manish-rai21bit

Maybe it will help someone: I faced this issue when I resized images (made them 50% smaller) but forgot to modify xml annotations accordingly.

polololya avatar Feb 20 '20 15:02 polololya