-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Hi. I'm trying to understand the function here
fully-convolutional-point-network/fcpn.py
Line 115 in 5942685
def get_spatial_pool_weighting(sphere_radius, top_level_centroid_locations): |
Not clear about what it does.
Below I try to go through the algorithm.
def get_spatial_pool_weighting(sphere_radius, top_level_centroid_locations):
""" Compute a spatial weighting for every cell.
Args:
sphere_radius: float, the weight of neighboring cells will be greatest on this sphere's surface
top_level_centroid_locations: tf.tensor, locations of cells in metric space
Returns: tf.tensor
"""
top_level_centroid_locations_repeated = tf.tile(tf.expand_dims(top_level_centroid_locations, axis=1), [1, top_level_centroid_locations.get_shape()[1].value, 1, 1]) #row-wise repeated sample locations
As top_level_centroid_locations
has shape (batch_size, num_points, 3)
I expect top_level_centroid_locations_repeated
shape to be (batch_size, num_points, num_points, 3)
difference = tf.subtract(top_level_centroid_locations_repeated, tf.transpose(top_level_centroid_locations_repeated, [0, 2, 1, 3]))
# Euclidean distance from every centroid to every other centroid
distance = tf.norm(difference, axis=3, ord=2, keepdims=True)
distance shape should be: (batch_size, num_points, num_points, 1). Is it?
# Clipped distance in [sphere_radius - 1, sphere_radius + 1] range
clipped_distance = tf.clip_by_value(distance, sphere_radius - 1, sphere_radius + 1)
# Neighboring voxels weighting based on (cos(3(x-1.5)) + 1) / 2, max weighting on voxels sphere_radius away from a given voxel
cos_distance_to_sphere_surface = (tf.cos(3 * (clipped_distance - sphere_radius)) + 1) / 2
# Normalized weighting
return cos_distance_to_sphere_surface / tf.reduce_sum(cos_distance_to_sphere_surface, axis=2, keepdims=True)
The output should still be in shape (batch_size, num_points, num_points, 1).
At line
fully-convolutional-point-network/fcpn.py
Line 284 in 5942685
skip_spatial_pool = features * spatial_pooling_weights |
features shape should be: (batch_size, num_points, num_points, 512).
Doing
features * spatial_pooling_weights
should output a shape of (batch_size, num_points, num_points, 512) thanks to broadcasting. Is it right?
Thank you in advance.
Metadata
Metadata
Assignees
Labels
No labels