(self, model, data, device)
return samplenet_loss, sampled_data, samplenet_loss_info
Sample point clouds using SampleNet and compute sampling associated losses.
Sample point clouds using SampleNet and compute sampling associated losses.
Sample point clouds using SampleNet and compute sampling associated losses .
def compute_samplenet_loss(self, model, data, device):
        """Sample point clouds using SampleNet and compute sampling associated losses."""

        p0, p1, igt = data
        p0 = p0.to(device)  # template
        p1 = p1.to(device)  # source

        p1_simplified, p1_projected = model.sampler(p1)

        # Sampling loss
        p1_simplification_loss = model.sampler.get_simplification_loss(
            p1, p1_simplified, self.NUM_OUT_POINTS, self.GAMMA, self.DELTA
        )

        if self.NUM_SAMPLED_CLOUDS == 1:
            simplification_loss = p1_simplification_loss
            sampled_data = (p0, p1_projected, igt)

        elif self.NUM_SAMPLED_CLOUDS == 2:  # Sample template point cloud as well
            p0_simplified, p0_projected = model.sampler(p0)
            p0_simplification_loss = model.sampler.get_simplification_loss(
                p0, p0_simplified, self.NUM_OUT_POINTS, self.GAMMA, self.DELTA
            )
            simplification_loss = 0.5 * (
                p1_simplification_loss + p0_simplification_loss
            )
            sampled_data = (p0_projected, p1_projected, igt)

        # Projection loss
        projection_loss = model.sampler.get_projection_loss()

        samplenet_loss = self.ALPHA * simplification_loss + self.LMBDA * projection_loss

        samplenet_loss_info = {
            "simplification_loss": simplification_loss,
            "projection_loss": projection_loss,
        }

        return samplenet_loss, sampled_data, samplenet_loss_info
def compute_samplenet_loss ( self , model , data , device ) : p0 , p1 , igt = data p0 = p0 . to ( device ) # template p1 = p1 . to ( device ) # source p1_simplified , p1_projected = model . sampler ( p1 ) # Sampling loss p1_simplification_loss = model . sampler . get_simplification_loss ( p1 , p1_simplified , self . NUM_OUT_POINTS , self . GAMMA , self . DELTA ) if self . NUM_SAMPLED_CLOUDS == 1 : simplification_loss = p1_simplification_loss sampled_data = ( p0 , p1_projected , igt ) elif self . NUM_SAMPLED_CLOUDS == 2 : # Sample template point cloud as well p0_simplified , p0_projected = model . sampler ( p0 ) p0_simplification_loss = model . sampler . get_simplification_loss ( p0 , p0_simplified , self . NUM_OUT_POINTS , self . GAMMA , self . DELTA ) simplification_loss = 0.5 * ( p1_simplification_loss + p0_simplification_loss ) sampled_data = ( p0_projected , p1_projected , igt ) # Projection loss projection_loss = model . sampler . get_projection_loss ( ) samplenet_loss = self . ALPHA * simplification_loss + self . LMBDA * projection_loss samplenet_loss_info = { "simplification_loss" : simplification_loss , "projection_loss" : projection_loss , } return samplenet_loss , sampled_data , samplenet_loss_info