Skip to content

Spatial pool weights. Some clarifications needed. #8

@decadenza

Description

@decadenza

Hi. I'm trying to understand the function here

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

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

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