'Computes encoded object locations and corresponding confidences.
Flattens image_features and applies fully connected ops (with no
non-linearity) to predict box encodings and class predictions.  In this
setting, anchors are not spatially arranged in any way and are assumed to
have been folded into the batch dimension.  Thus we output 1 for the
anchors dimension.
Args:
image_features: A float tensor of shape [batch_size, height, width,
channels] containing features for a batch of images.
num_predictions_per_location: an integer representing the number of box
predictions to be made per spatial location in the feature map.
Currently, this must be set to 1, or an error will be raised.
Returns:
A dictionary containing the following tensors.
box_encodings: A float tensor of shape
[batch_size, 1, num_classes, code_size] representing the
location of the objects.
class_predictions_with_background: A float tensor of shape
[batch_size, 1, num_classes + 1] representing the class
predictions for the proposals.
If predict_masks is True the dictionary also contains:
instance_masks: A float tensor of shape
[batch_size, 1, num_classes, image_height, image_width]
If predict_keypoints is True the dictionary also contains:
keypoints: [batch_size, 1, num_keypoints, 2]
Raises:
ValueError: if num_predictions_per_location is not 1.'

def _predict(self, image_features, num_predictions_per_location):

    if (num_predictions_per_location != 1):
        raise ValueError('Currently    FullyConnectedBoxPredictor    only    supports    predicting    a    single    box    per    class    per    location.')
    spatial_averaged_image_features = tf.reduce_mean(image_features, [1, 2], keep_dims=True, name='AvgPool')
    flattened_image_features = slim.flatten(spatial_averaged_image_features)
    if self._use_dropout:
        flattened_image_features = slim.dropout(flattened_image_features, keep_prob=self._dropout_keep_prob, is_training=self._is_training)
    with slim.arg_scope(self._fc_hyperparams):
        box_encodings = slim.fully_connected(flattened_image_features, (self._num_classes * self._box_code_size), activation_fn=None, scope='BoxEncodingPredictor')
        class_predictions_with_background = slim.fully_connected(flattened_image_features, (self._num_classes + 1), activation_fn=None, scope='ClassPredictor')
    box_encodings = tf.reshape(box_encodings, [(-1), 1, self._num_classes, self._box_code_size])
    class_predictions_with_background = tf.reshape(class_predictions_with_background, [(-1), 1, (self._num_classes + 1)])
    predictions_dict = {BOX_ENCODINGS: box_encodings, CLASS_PREDICTIONS_WITH_BACKGROUND: class_predictions_with_background}
    if self._predict_instance_masks:
        with slim.arg_scope(self._conv_hyperparams):
            upsampled_features = slim.conv2d_transpose(image_features, num_outputs=self._mask_prediction_conv_depth, kernel_size=[2, 2], stride=2)
            mask_predictions = slim.conv2d(upsampled_features, num_outputs=self.num_classes, activation_fn=None, kernel_size=[1, 1])
            instance_masks = tf.expand_dims(tf.transpose(mask_predictions, perm=[0, 3, 1, 2]), axis=1, name='MaskPredictor')
        predictions_dict[MASK_PREDICTIONS] = instance_masks
    return predictions_dict
