【Hackathon 8th No.11】DrivAerNet++ 论文复现 by LilaKen · Pull Request #1062 · PaddlePaddle/PaddleScience (original) (raw)

# Ensure x is in the shape (bs, C, L)
if len(x.shape) != 3:
raise ValueError(
f"Input tensor should have shape (batch_size, C, L), but got {x.shape}"
)
# Initialize an empty list to store the processed samples
processed_samples = []
# Apply data augmentation and normalization for each sample in the batch
augmentation = DataAugmentation()
for i in range(bs):
sample = x[i].numpy() # Convert to numpy array for data augmentation
sample = augmentation.translate_pointcloud(sample)
sample = augmentation.jitter_pointcloud(sample)
sample = self.min_max_normalize(sample)
processed_samples.append(sample)
# Stack the processed samples back into a batch tensor
x_processed = paddle.to_tensor(np.stack(processed_samples, axis=0))
# Ensure the processed tensor has the same shape as the original input
if x_processed.shape != x.shape:
raise ValueError(
f"Processed tensor shape {x_processed.shape} does not match original input shape {x.shape}"
)