'Embed all given tensors into an nfeatures-dim space.'

def embed(self, x, nfeatures=2):

    list_split = 0
    if isinstance(x, list):
        list_split = len(x)
        x = tf.concat(x, 0)
    x = tf.expand_dims(x, 3)
    x = ((x * 2) - 1)
    net = slim.layers.conv2d(x, 20, 5, scope='conv1')
    net = slim.layers.max_pool2d(net, 2, scope='pool1')
    net = slim.layers.conv2d(net, 50, 5, scope='conv2')
    net = slim.layers.max_pool2d(net, 2, scope='pool2')
    net = slim.layers.flatten(net, scope='flatten3')
    net = slim.layers.fully_connected(net, 500, scope='fully_connected4')
    embeddings = slim.layers.fully_connected(net, nfeatures, activation_fn=None, scope='fully_connected5')
    if (list_split > 0):
        embeddings = tf.split(embeddings, list_split, 0)
    return embeddings
