Skip to content

Commit

Permalink
fix of error: TypeError: (InvalidType) Type promotion only support ca…
Browse files Browse the repository at this point in the history
…lculations 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]>
  • Loading branch information
Pecako2001 and WerkPC authored Jul 27, 2024
1 parent 9f107da commit 104afd3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rtdetr_paddle/ppdet/modeling/transformers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,18 @@ def get_contrastive_denoising_training_group(targets,
if label_noise_ratio > 0:
input_query_class = input_query_class.flatten()
pad_gt_mask = pad_gt_mask.flatten()

# Convert pad_gt_mask to bool if it's not already
pad_gt_mask = pad_gt_mask.astype('bool')

# half of bbox prob
mask = paddle.rand(input_query_class.shape) < (label_noise_ratio * 0.5)
chosen_idx = paddle.nonzero(mask * pad_gt_mask).squeeze(-1)

# randomly put a new one here
new_label = paddle.randint_like(
chosen_idx, 0, num_classes, dtype=input_query_class.dtype)

input_query_class.scatter_(chosen_idx, new_label)
input_query_class.reshape_([bs, num_denoising])
pad_gt_mask.reshape_([bs, num_denoising])
Expand Down

0 comments on commit 104afd3

Please sign in to comment.