'Add the fully-connected logits and SoftMax/Logistic output Layer.
Args:
prev_layer:  Output of last layer of main network.
out_dims:    Number of output dimensions, 0, 1 or 2.
out_func:    Output non-linearity. \'s\' or \'c\'=softmax, \'l\'=logistic.
num_classes: Number of outputs/size of last output dimension.
Returns:
logits:  Pre-softmax/logistic fully-connected output shaped to out_dims.
outputs: Post-softmax/logistic shaped to out_dims.
Raises:
ValueError: if syntax is incorrect.'

def _AddOutputLayer(self, prev_layer, out_dims, out_func, num_classes):

    batch_in = shapes.tensor_dim(prev_layer, dim=0)
    height_in = shapes.tensor_dim(prev_layer, dim=1)
    width_in = shapes.tensor_dim(prev_layer, dim=2)
    depth_in = shapes.tensor_dim(prev_layer, dim=3)
    if out_dims:
        shaped = tf.reshape(prev_layer, [(-1), depth_in])
    else:
        shaped = tf.reshape(prev_layer, [(-1), ((height_in * width_in) * depth_in)])
    logits = slim.fully_connected(shaped, num_classes, activation_fn=None)
    if (out_func == 'l'):
        raise ValueError('Logistic    not    yet    supported!')
    else:
        output = tf.nn.softmax(logits)
    if (out_dims == 2):
        output_shape = [batch_in, height_in, width_in, num_classes]
    elif (out_dims == 1):
        output_shape = [batch_in, (height_in * width_in), num_classes]
    else:
        output_shape = [batch_in, num_classes]
    output = tf.reshape(output, output_shape, name='Output')
    logits = tf.reshape(logits, output_shape)
    return (logits, output)
