Skip to content

Commit 104afd3

Browse files
KoenvanWijlickWerkPC
andauthored
fix of error: TypeError: (InvalidType) Type promotion only support calculations between floating-point numbers and between complex and real numbers. But got different data type x: bool, y: float32. (at ../paddle/phi/common/type_promotion.h:164) (#387)
Co-authored-by: WerkPC <[email protected]>
1 parent 9f107da commit 104afd3

File tree

1 file changed

+6
-0
lines changed
  • rtdetr_paddle/ppdet/modeling/transformers

1 file changed

+6
-0
lines changed

rtdetr_paddle/ppdet/modeling/transformers/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,18 @@ def get_contrastive_denoising_training_group(targets,
299299
if label_noise_ratio > 0:
300300
input_query_class = input_query_class.flatten()
301301
pad_gt_mask = pad_gt_mask.flatten()
302+
303+
# Convert pad_gt_mask to bool if it's not already
304+
pad_gt_mask = pad_gt_mask.astype('bool')
305+
302306
# half of bbox prob
303307
mask = paddle.rand(input_query_class.shape) < (label_noise_ratio * 0.5)
304308
chosen_idx = paddle.nonzero(mask * pad_gt_mask).squeeze(-1)
309+
305310
# randomly put a new one here
306311
new_label = paddle.randint_like(
307312
chosen_idx, 0, num_classes, dtype=input_query_class.dtype)
313+
308314
input_query_class.scatter_(chosen_idx, new_label)
309315
input_query_class.reshape_([bs, num_denoising])
310316
pad_gt_mask.reshape_([bs, num_denoising])

0 commit comments

Comments
 (0)