'Parse expression and add Fully Connected Layer.
Args:
prev_layer: Input tensor.
index:      Position in model_str to start parsing
Returns:
Output tensor, end index in model_str.'

def AddFCLayer(self, prev_layer, index):

    pattern = re.compile('(F)(s|t|r|l|m)({\\w+})?(\\d+)')
    m = pattern.match(self.model_str, index)
    if (m is None):
        return (None, None)
    fn = self._NonLinearity(m.group(2))
    name = self._GetLayerName(m.group(0), index, m.group(3))
    depth = int(m.group(4))
    input_depth = ((shapes.tensor_dim(prev_layer, 1) * shapes.tensor_dim(prev_layer, 2)) * shapes.tensor_dim(prev_layer, 3))
    shaped = tf.reshape(prev_layer, [(-1), input_depth], name=(name + '_reshape_in'))
    output = slim.fully_connected(shaped, depth, activation_fn=fn, scope=name)
    self.reduction_factors[1] = None
    self.reduction_factors[2] = None
    return (tf.reshape(output, [shapes.tensor_dim(prev_layer, 0), 1, 1, depth], name=(name + '_reshape_out')), m.end())
