ThibaultGROUEIX / ChamferDistancePytorch

Chamfer Distance in Pytorch with f-score
MIT License
336 stars 45 forks source link

How to deal with the different dimension requirement of network and loss #8

Closed SkyeFromKindergarten closed 3 years ago

SkyeFromKindergarten commented 4 years ago

Thanks for your work~ I have one question. For pytorch codes, the input shape of a network is (B,C,N). B for benchmark, C for channles(for point clouds coordinates, C=3, just like here ) and N for N points. So the output of network should be (B,C,N) too. But a (B,N,C)-shape input is required for ChamferLoss. I want to know what should I do to unify the dimensions of these two requirments? For now, I do as follows:

input = input.transpose(2,1) # My input/gt is (B,N,C). so (B,N,C) => (B,C,N) and C = 3 output = net(input) # (B,C,N) loss = ChamferLoss(output.transpose(2,1), groundtruth) # output (B,C,N) => (B,N,C)

Hope I discribed my confusion clearly. Looking for your reply. Best regards.

ThibaultGROUEIX commented 4 years ago

Hi @SkyeFromKindergarten, I am not sure what is the question here. The input of chamfer shound be : batch x number_points x 3 Cheers, Thibault