Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Train error #20

Open
AlessandroZoia-dev opened this issue Nov 29, 2020 · 2 comments · May be fixed by #28
Open

Train error #20

AlessandroZoia-dev opened this issue Nov 29, 2020 · 2 comments · May be fixed by #28

Comments

@AlessandroZoia-dev
Copy link

I executed the train_model.pynb but I have the following error:

InvalidArgumentError Traceback (most recent call last)

in
4 with tf.GradientTape() as tape:
5 rpn_class_loss, rpn_bbox_loss, rcnn_class_loss, rcnn_bbox_loss =
----> 6 model((batch_imgs, batch_metas, batch_bboxes, batch_labels), training=True)
7
8 loss_value = rpn_class_loss + rpn_bbox_loss + rcnn_class_loss + rcnn_bbox_loss

D:\faster2\detection\models\detectors\faster_rcnn.py in call(self, inputs, training)
133 rois, rcnn_labels, rcnn_label_weights, rcnn_delta_targets, rcnn_delta_weights =
134 self.bbox_target.build_targets(
--> 135 proposals, gt_boxes, gt_class_ids, img_metas)
136 else:
137 rois = proposals

D:\faster2\detection\core\bbox\bbox_target.py in build_targets(self, proposals, gt_boxes, gt_class_ids, img_metas)
71 for i in range(batch_size):
72 rois, labels, label_weights, delta_targets, delta_weights = self._build_single_target(
---> 73 proposals[i], gt_boxes[i], gt_class_ids[i], pad_shapes[i], i)
74 rcnn_rois.append(rois)
75 rcnn_labels.append(labels)

D:\faster2\detection\core\bbox\bbox_target.py in _build_single_target(self, proposals, gt_boxes, gt_class_ids, img_shape, batch_ind)
177 tile_delta_weights = tf.zeros((self.num_rcnn_deltas, self.num_classes, 4))
178 ids = tf.stack([tf.range(self.num_rcnn_deltas, dtype=labels.dtype), labels], axis=1)
--> 179 delta_targets = tf.tensor_scatter_nd_update(tile_delta_targets, ids, delta_targets) # [num_rois, self.num_classes, 4]
180 delta_weights = tf.tensor_scatter_nd_update(tile_delta_weights, ids, delta_weights) # [num_rois, self.num_classes, 4]
181

C:\ProgramData\Anaconda3\envs\faster\lib\site-packages\tensorflow_core\python\ops\gen_array_ops.py in tensor_scatter_update(tensor, indices, updates, name)
11081 else:
11082 message = e.message

11083 _six.raise_from(_core._status_to_exception(e.code, message), None)
11084 # Add nodes to the TensorFlow graph.
11085 try:

C:\ProgramData\Anaconda3\envs\faster\lib\site-packages\six.py in raise_from(value, from_value)

InvalidArgumentError: indices[212] = [212, -1] does not index into shape [256,81,4] [Op:TensorScatterUpdate]

Can you help me to understand the problem? Thank you.

@Jackluisus
Copy link

I got the same question here

@khatchad
Copy link
Contributor

khatchad commented Aug 1, 2024

Changing the following line:

labels = tf.pad(labels, [(0, P)], constant_values=-1) # [num_rois]

to match the one above it:

labels = tf.pad(labels, [(0, P)], constant_values=0) # [num_rois] 

seems to make the training go through.

khatchad added a commit to khatchad/tf-eager-fasterrcnn that referenced this issue Aug 1, 2024
@khatchad khatchad linked a pull request Aug 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants