def test_box_center_distance_loss_on_voxel_tensors_relative(self): (inputs, outputs1, outputs2) = self._get_dictionaries_for_distance_loss_relative() inputs[standard_fields.InputDataFields.num_valid_voxels] = tf.constant( [1], dtype=tf.int32) loss1 = box_prediction_losses.box_center_distance_loss_on_voxel_tensors( inputs=inputs, outputs=outputs1, loss_type='huber') loss2 = box_prediction_losses.box_center_distance_loss_on_voxel_tensors( inputs=inputs, outputs=outputs2, loss_type='huber') self.assertGreater(loss2.numpy(), loss1.numpy())
def test_box_center_distance_loss_on_voxel_tensors_empty_inputs(self): inputs = self._get_empty_inputs() outputs = { standard_fields.DetectionResultFields.object_center_voxels: tf.zeros([1, 0, 3], dtype=tf.float32), } loss = box_prediction_losses.box_center_distance_loss_on_voxel_tensors( inputs=inputs, outputs=outputs, loss_type='huber') self.assertAllClose(loss.numpy(), 0.0)
def test_box_center_distance_loss_on_voxel_tensors_correct_prediction( self): inputs = self._get_random_inputs() inputs[standard_fields.InputDataFields.num_valid_voxels] = tf.constant( [100], dtype=tf.int32) outputs = { standard_fields.DetectionResultFields.object_center_voxels: inputs[standard_fields.InputDataFields.object_center_voxels], } loss = box_prediction_losses.box_center_distance_loss_on_voxel_tensors( inputs=inputs, outputs=outputs, loss_type='huber') self.assertAllClose(loss.numpy(), 0.0)