Use torch.max instead of torch.nn.MaxPool1d #18
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
According to the original paper, there should be no restriction on the number of points within a point cloud. This PR updates the pointnet to allow for variable number of points within a pointcloud or from mini-batch to mini-batch.
If one has a dataset that has different numbers of points within each point cloud, one way of using this is to upsample (similar to how images are padded with 0s when they are different sizes). However, one wants to minimize the number of added points because unlike image data, adding 0s in a point cloud changes the structure of the data. Instead, one should duplicate the fewest number of points such that each sample in a mini-batch has the same number of points but each mini-batch may have a different number of points per sample.
To do this, one should sort their dataset by the number of points within each point cloud, then group the point clouds into sizes of the desired mini-batch. For example one mini-batch may have point clouds of sizes:
[901, 905, 905, ..., 945]
.In order to upsample all pointclouds
P
inmini-batch_j
, one randomly duplicatesK
points from a pointcloudP_i
withN
points whereK
is the difference between the current pointcloud size and the maximum pointcloud size inmini-batch_j
(K = max(P_i.size() for P_i in mini-batch_j) - N
).For example, the previous example, the mini-batch will now have sizes
[945, 945, 945, ..., 945]
because the first pointcloud with size901
had (945 - 901
)44
points duplicated, etc. Now that each mini-batch has the same number of points, one can train their network by randomly sampling these mini-batches.