Skip to content

Generated point clouds look different when using batches #8

@ArmanMaesumi

Description

@ArmanMaesumi

Hi, thank you for releasing the code base!

I encountered a strange issue. When I generate point clouds, my results are different depending on if I do it sequentially, or as a batch. Here is a small example (running inside model_test.py):

with torch.no_grad():
    batch_size = 10

    # generate random latent matrices for 10 shapes
    noise = self.noise_generator(bs=batch_size)

    # First try passing noise through model one at a time (sequentially)
    x = self.sphere_generator(bs=1)
    pcs_sequential= np.zeros((batch_size, 2048, 3))
    for i, latent_matrix in enumerate(noise):
        out_pc = self.G(x, latent_matrix[None])
        out_pc = out_pc.transpose(2, 1)
        out_pc = out_pc.cpu().detach().numpy()
        out_pc = normalize_point_cloud(out_pc)
        pcs_sequential[i] = out_pc 
    
    for i in range(batch_size): # Render results
        pyplot_draw_point_cloud(pcs_sequential[i], output_filename=f'nobatch_{i}.png')

    # Now try running all noise through model (full batch) 
    x = self.sphere_generator(bs=batch_size)
    
    out_pc = self.G(x, noise)
    out_pc = out_pc.transpose(2,1)

    pcs_batching = out_pc.cpu().detach().numpy()
    pcs_batching = normalize_point_cloud(pcs_batching)
    print (pcs_sequential - pcs_batching) # <--- We should expect this to be all zeros
    
    for i in range(batch_size): # Render results
        pyplot_draw_point_cloud(pcs_batching[i], output_filename=f'batch_{i}.png')

Here the point clouds generated sequentially and the point clouds generated in a batch are different. When I compute pcs_sequential - pcs_batching the values are non-zero, and the rendered point clouds are visibly different.

Any help would be appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions