def test_box_corner_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_corner_distance_loss_on_voxel_tensors( inputs=inputs, outputs=outputs1, loss_type='normalized_huber') loss2 = box_prediction_losses.box_corner_distance_loss_on_voxel_tensors( inputs=inputs, outputs=outputs2, loss_type='normalized_huber') self.assertGreater(loss2.numpy(), loss1.numpy())
def test_box_corner_distance_loss_on_voxel_tensors_empty_inputs(self): inputs = self._get_empty_inputs() inputs[standard_fields.InputDataFields.num_valid_voxels] = tf.constant( [0], dtype=tf.int32) outputs = { standard_fields.DetectionResultFields.object_rotation_matrix_voxels: tf.zeros([1, 0, 3, 3], dtype=tf.float32), standard_fields.DetectionResultFields.object_length_voxels: tf.zeros([1, 0, 1], dtype=tf.float32), standard_fields.DetectionResultFields.object_height_voxels: tf.zeros([1, 0, 1], dtype=tf.float32), standard_fields.DetectionResultFields.object_width_voxels: tf.zeros([1, 0, 1], dtype=tf.float32), standard_fields.DetectionResultFields.object_center_voxels: tf.zeros([1, 0, 3], dtype=tf.float32), } loss = box_prediction_losses.box_corner_distance_loss_on_voxel_tensors( inputs=inputs, outputs=outputs, loss_type='normalized_huber') self.assertAllClose(loss.numpy(), 0.0)