examples/nerf.py
def _get_colors(self, features, rays_directions):
        """
        This function takes per-point `features` predicted by `self.mlp`
        and evaluates the color model in order to attach to each
        point a 3D vector of its RGB color.

        In order to represent viewpoint dependent effects,
        before evaluating `self.color_layer`, `NeuralRadianceField`
        concatenates to the `features` a harmonic embedding
        of `ray_directions`, which are per-point directions
        of point rays expressed as 3D l2-normalized vectors
        in world coordinates.
        """
        spatial_size = features.shape[:-1]

        # Normalize the ray_directions to unit l2 norm.
        rays_directions_normed = torch.nn.functional.normalize(
            rays_directions, dim=-1
        )

        # Obtain the harmonic embedding of the normalized ray directions.
        rays_embedding = self.harmonic_embedding(
            rays_directions_normed
        )

        # Expand the ray directions tensor so that its spatial size
        # is equal to the size of features.
        rays_embedding_expand = rays_embedding[..., None, :].expand(
            *spatial_size, rays_embedding.shape[-1]
        )

        # Concatenate ray direction embeddings with
        # features and evaluate the color model.
        color_layer_input = torch.cat(
            (features, rays_embedding_expand),
            dim=-1)
        return self.color_layer(color_layer_input)

        This function takes per-point `features` predicted by `self.mlp`
        and evaluates the color model in order to attach to each
        point a 3D vector of its RGB color.

        In order to represent viewpoint dependent effects,
        before evaluating `self.color_layer`, `NeuralRadianceField`
        concatenates to the `features` a harmonic embedding
        of `ray_directions`, which are per-point directions
        of point rays expressed as 3D l2-normalized vectors
        in world coordinates.
        
This function takes per-point `features` predicted by `self.mlp`
and evaluates the color model in order to attach to each
point a 3D vector of its RGB color.


This function takes per - point ` features ` predicted by ` self . mlp ` and evaluates the color model in order to attach to each point a 3D vector of its RGB color .
def _get_colors(self, features, rays_directions):
        spatial_size = features.shape[:-1]
        rays_directions_normed = torch.nn.functional.normalize(
            rays_directions, dim=-1
        )
        rays_embedding = self.harmonic_embedding(
            rays_directions_normed
        )
        rays_embedding_expand = rays_embedding[..., None, :].expand(
            *spatial_size, rays_embedding.shape[-1]
        )
        color_layer_input = torch.cat(
            (features, rays_embedding_expand),
            dim=-1)
        return self.color_layer(color_layer_input)
def _get_colors ( self , features , rays_directions ) : spatial_size = features . shape [ : - 1 ] rays_directions_normed = torch . nn . functional . normalize ( rays_directions , dim = - 1 ) rays_embedding = self . harmonic_embedding ( rays_directions_normed ) rays_embedding_expand = rays_embedding [ ... , None , : ] . expand ( * spatial_size , rays_embedding . shape [ - 1 ] ) color_layer_input = torch . cat ( ( features , rays_embedding_expand ) , dim = - 1 ) return self . color_layer ( color_layer_input )
This function takes per-point `features` predicted by `self.mlp`
and evaluates the color model in order to attach to each
point a 3D vector of its RGB color.
This function takes per - point ` features ` predicted by ` self . mlp ` and evaluates the color model in order to attach to each point a 3D vector of its RGB color .
"""
        This function takes per-point `features` predicted by `self.mlp`
        and evaluates the color model in order to attach to each
        point a 3D vector of its RGB color.

        In order to represent viewpoint dependent effects,
        before evaluating `self.color_layer`, `NeuralRadianceField`
        concatenates to the `features` a harmonic embedding
        of `ray_directions`, which are per-point directions
        of point rays expressed as 3D l2-normalized vectors
        in world coordinates.
        """ # Normalize the ray_directions to unit l2 norm. # Obtain the harmonic embedding of the normalized ray directions. # Expand the ray directions tensor so that its spatial size # is equal to the size of features. # Concatenate ray direction embeddings with # features and evaluate the color model.
self
features
rays_directions